Bex calculation

Hello gurus,
I have the data in the cube as follows.
structure of data for january month is as follows:-
costcenter -
   char.Infoobject -
    keyfigure (Quantity)
200 -
             A  -
                  1000     
200 -
             B  -
                    20%
200 -
             C  -
          50%
200 -
             D  -
          30%
200 -
             E  -
          40%
similarly structure of data for february month:-
200 -
            A -
          2500     
200 -
            B -
          35%
200 -
            C -
                  45%
200 -
            D -
        25%
200 -
            E -
              65%
and i have the similar data for all months.
And accordingly, I have the similar data for several costcenters and all months.
(For ex: - for other costcenters, only the quantity values will be changed).
A, B, C, D …. values are identified based on costcenter and fiscper.
my  yeartodate webreport  for january in the browser looks like as follows:-
costcenter(200)----costcenter(300)     
A -
1000  -
3000
B----
20      -
23
C----
50      -
36                      
D----
30
E
similarly my  webreport  for february in the browser looks like as follows:-
costcenter(200)---- costcenter(300)     
A -
3500  -
6500
B----
30.71 -
26
C----
46.42 -
42                      
D
I would like to calculate year to date weighted average for one costcenter as follows.
I have to get the data when the user enters the month in the selection screen.
Note: - here A, B, C, D ….. are related to same costcenter (i.e. it should not take other costcenters values)
formula for the record B for january
[jan(A) * jan (B)] / jan(A)   i.e. [1000*20] / 1000
formula for the record B for february
[jan(A) * jan (B) + feb (A) * feb (B)] / [jan(A) + feb (A)] 
i.e [(100020) + (250035)] / [1000 + 2500] = 30.71
formula for the record B for march
[jan(A) * jan (B) + feb (A) * feb (B) + mar (A) * mar (B)] / [jan(A) + feb (A) + mar (A)] 
formula for the record B for april
[jan(A) * jan (B) + feb (A) * feb (B) + mar (A) * mar (B) + april (A) * april (B)  ] / [jan(A) + feb (A) + mar (A) + april (A)] 
Similarly for all months…………..
I need to calculate using the same formula for the records C, D, E …….. also
For ex:- formula for the record C for february
[jan(A) * jan (C) + feb (A) * feb (C)] / [jan(A) + feb (A)]  = 46.42
formula for the record C for march
[jan(A) * jan (C) + feb (A) * feb (C) + mar (A) * mar (C)] / [jan(A) + feb (A) + mar (A)] 
Similarly for all months.
Any help will be really appreciated.
Thanks & Regards
Kumar

Kumar,
you could do it with:
1. Have all the values in the report and have the formulae with the unnecessary values hidden - here you would have one query with all the values for Jan - Dec and have the formulae accordingly.
Now you can go about creating a view for the relevant months and expose the necessary report for January - here you would have one Query with 12 Key figures each restricted by month and 12 formulae , on this you would have 12 views which correspond to the web templates.
2. You could have virtual Key Figures and do the same using ABAP - but this would be more complicated
3. You could instead store the values into an ODS before publishing into the report if you have performance issues.
Arun
Assign points if useful

Similar Messages

  • Can you share Bex Calculated Key Figures in BI-IP

    We have a requirement to establish P&L planning for a company.  Two questions:
    1. There are a number of calculations that are required for various values (i.e. current month, previous month, current month contract to date, previous month contract to date).  I am trying to determine if I should build these calculations into the query using C-KFs or apply them during ETL as multiple cumulative key figures?  Data volume is small (200 records a month) so we were thinking a key figure based model (instead of using cost elements) for this as they don't utilize FI in ECC in a typical fashion.
    2. After we get this initial data into SAP BI for reporting, we would like simulate it using plan/forecast versions.  In BI-IP I learned that it can use R-KF & C-KF as it uses BeX.  If I create a bunch of C-KFs, can I utilize those calculations in BI-IP so I don't have to create FOX formulas for them?
    Thanks!

    Thanks for your responses.... Unfortuntately, I need to plan on some of these values so it sounds like CKFs won't work for me.  I wonder why SAP claims BI-IP can utilize CKFs if you can't save any of the results of these?  Is it possible to save them as planning items?  
    Also, if I have to do formula/ABAP transformations on the update rules for the flat files coming in, can I leverage any of that in BI-IP if they are on the same infoprovider?  I know FOX fairly well and can off-set time periods (i.e. current month, previous month), but I don't know how to cumulative values in the ABAP routines nor time periods off-sets.
    Please advise if there are any good sources for this documentation.
    Thanks so much!
    -Matt
    [email protected]

  • SAP BEX Calculated Column

    Hi ,
    I would like to thanks to all who helped me in getting my work done for my previous questions.
    This time i came up with some new questions ... is there a way to create a calculated column in the SAP BEx query ? I dont have global query edit permissions but i can chage the Local View of the query.
    1 )
    I have a Original Hire Date and Most Recent Hire Date as two columns in the BEX Query, when i refresh the query it will populate in tow different columns which is usual. But, i would like to combine these two DATE columns (based on some criteria) as one and want to produce as a single DATE columns.
    would it be possible... ?
    2)
    I have two query's in a workbook and the first query will give the employees ID's which i have import in the second query. Is ther any way to import these ID's in to Second query automatically through VBA or some other code ... ?
    Thanks in Advance for you kind help.

    Hello,
    Both are possible.
    1) Please go through the following links:
    due date minus current date
    http://forums.sdn.sap.com/search.jspa?q=date%20bucket&objID=c4&dateRange=all&searchID=72203772&rankBy=10001&start=30
    2) Id directly can not import into the query. but you can display at the end of the query(Left,right,Top,Bottom). You have to use simple excel formula : =+sheet1!A1. It will display all values from sheet1 starting from cell A1 in sheet2 .
    Thanks.
    Please let me know if you need further help.
    Thanks.
    With regards,
    Anand Kumar

  • BEx - Calculated/Restricted KF

    I am trying to create the following:
    Show me all sales orders where confirmed date is greater than cancel date?
    All 3 are characteristics and not key figures.
    Any suggestions?

    Hi,
    you could also try to use variables in calculated key figures with replacement path.
    See: http://help.sap.com/saphelp_nw04/helpdata/en/03/6ba03cc24efd1de10000000a114084/frameset.htm
    and
    http://help.sap.com/saphelp_nw04/helpdata/en/ca/5f9ac61a205a459d0e7ef313d10321/frameset.htm
    use the formula and conditions as Roberto described.
    Heike
    Message was edited by: Heike Guder

  • BEx calculation for 'average sales order value'

    Hi all,
    Can someone tell me how to use BEx query function to compute the <b>'average sales order values' by month</b>? Thank you.
    J.

    Hi John,
         You've two characteristics in the rows, right? Calendar Month and Order Type.
    Try the option Calculate Result as Average of All Values and
    Calculate Single Value as Nothing Defined? See if this works.
    Or else in Modelling,
    In the Info Object Create/Change screen, you can specify an Exception Aggregation based on
    <b>Aggregate Reference Characteristic</b> Calendar Month.
    I think there's an option for Average Values in the <b>Exception Aggregation</b> tab.
    For more Information,
    http://help.sap.com/saphelp_nw04/helpdata/en/75/21054da1392649948e5b94e4fc4bce/content.htm
    Hope this helps.
    Regards
    Hari
    Message was edited by: Hari Krishnan K

  • Hi - Bex Calculation & Conditions

    Hi All,
    We have a report by Material, Customer & Week. showing the Demand(KF1) for 10 future weeks.
    I need a condition to display the Demand, only if KF 2 is greater than 0(Greater than 0 in any of the 10 weeks).
    If i use 'Conditions', it is displaying the KF value only for the week, when the KF 2 is greater than 0.
    I have created a formula using 'SUMGT' to display the total next to each record and wanted to use the formula in a 'Count' funtion.
    However, when i create this formula, its summing up all the Material & Customers and displaying the Total result.
    Where as, i want the result of each Material - Customer combination.
    Thanks,
    Nisha

    Hi,
    Create a CKF KF3 = KF1*KF2
    Set Query properties to display 0 as blank.
    Also suppress Zeros.
    Display KF3 instead of KF1.
    -Vikram

  • How to add unit to calculated key figures in BEx

    How to add unit to BEx calculated key figures in SAP BW BEx?
    I would like to add a unit to a calculated key figure in SAP BW BEx, so that it gets visible on the end user level. Currently the unit field is empty. I calculated the value from various key figures with different units and removed the units with the NODIM()-function. Is there an inverse function to NODIM() with which you can add a specific unit (like EUR or TAG).
    The "How tou2026 Report Data in Alternate Units of Measure" does not seem to cover the point.
    "Quantity Conversion Guide for SAP Business Intelligence" refers to the "Conversion" tab.
    I suppose you have to add a conversion routine, which is 1:1 and sets the target unit defined in BEx.
    Has anyone tried this? Is there a more simple solution?
    OLAP-Quantity Conversion:
    http://help.sap.com/saphelp_nw70/helpdata/EN/27/b65c42b4e05542e10000000a1550b0/frameset.htm

    Hi,
    if your CKF will have always same unit and you have one KF in you inforpovider with this unit, you can try to do this trick
    create a new hidden CKF as new CKF = KF / KF (with this equale new CKF = 1 unit)
    change your old CKF as old CKF = old CKF * new CKF
    let me know if it works.

  • Calculated Key Figures in IP FOX

    Hi,
    I would like to modify the calculated key figures using custom Formula planning fuction (FOX). Can some one let me know how to change these calculated key figures from BEx.
    I have found a thread discussing the same topic.
    Business Planning
    So do we have to definitely create a key figure in real time cube to be able to change the values in BEx calculated key figure.
    this is only for simulation purpose based on some key figure values and not for storing values in the cube.
    Regards
    Bhav

    Hi,
    If I understood correctly, you are asking why we have that "planning" tab in the properties of Calc KFs also? I think its just that the properties tab for all KFs is the same (no special customizing for any kind of KF), but it obviously doesn't make sense to set planning properties for calc KFs.

  • Dimension selection for chart in Design Studio

    Hello everyone,
         I have created a data source as shown below. Now i need only sales group dimension to be selected in my chart, i don't want to remove plant and material from my data source as it will give incorrect summation result i.e weighted avg.(weighted avg is based on other two key figure in bex, calculation is at detailed level then sum up weighted avg.)
    Is there any option to select the dimension? or Is there any option to calculate by summing up all the weight avg. by sales group wise and store that data in JSON then use it in the chart?
    Sales Group    Plant    Material    weight avg.
    A                       A1    A11        100
    A                       A1    A12        75
    A                       A2    A21        75
    A                       A2    A22        100
    A                       A2    A23        50
    A                       A3    A31        150
    B                       B1    B11        200
    B                       B1    B12        10
    B                       B2    B21        20
    B                       B2    B22        20
    B                       B2    B23        50
    B                       B3    B31        70
    Thank you in Advance

    thx for reply!
    I actually don't have a filter..

  • Difference between  aggregation and calculation tab in BEx Query Designer

    HI,
    I am using BEx Query Designer for my report, for the key figures in the coloumn area i slected one numeric key figures, in  the properties tab i found aggregation tab and calculation tab.
    I need to sum up the total values for that particualar coloumn, when i used calculation tab i found to sum all the values for a particular coloumn, then what is the use the aggreagation tab?
    I not able to used that Aggregation tab it is showing as a hidden fields...
    can any one tell me whats the exact difference between these tabs and when we need to use which tab?
    With Regards,
    Thanesh Kumar.

    Hi Thanesh Kumar,
    I moved this thread from forum Data Warehousing to Business Explorer since it is a query related question (as SDN moderator).
    I could explain to you the difference between these two tabs.
    For "calculation" tab, it changes the display of result and does not change the calculation logic.
    It means that, if this key figure is used further in formula, still the original number (without "calculation" tab setting)  is used for further formula calculation.
    For "aggregation" tab, it changes the real calculation logic.
    The system takes the setting as the aggregation rule for records.
    The most common aggregation rule is of course summation. If you set to e.g. Average here, the system does the
    Average instead of summation when aggregating records. And the Average value will be taken for calculation
    in further formulas or other calculations.
    For "aggregation" tab, you could only use it for CKF (calculated key figure) or formula and you could not use it for
    a basic key figure. That should be the reason why you see it greyed-out.
    Regards,
    Patricia

  • Problem in Calculated Key Figure in BEx 7.0

    Hi All,
    In Bex 7.0
    We have a requirement where we need to display a key figure which is having unit price of an Article. In our InfoProvider we have Article, Store and Date and the report is based on Article. As we have to display only the latest price we have created a RKF by putting a restrcition of the latest date in the date range on the the unit price key figure. But still unit price is getting aggregated over stores.
    For example if there are 10 stores and the unit price of an article is 5, then data displayed is 50 and not 5.
    We tried to create a Calculated Key Figure using the above RKF and an exception aggregation Average of all detailed value that are not zero, null or error on reference characteristic 0PLANT. Its working fine when the query is restricted to one or two Articles. But for all the articles it gives the following error messages.
    1. Error while reading data; navigation is possible.
    2. Error occurred during parallel processing of query 17; RC3
    3. Error executing physical plan: AttributeEngine: no 6952
    4. Error reading the data of infoprovider ZXMSC01$X
    5. Amount of data that is to be read from the BIA server is too large
    6. The following error 6952 occurred in BIA server
    7. Error executing physical plan: AttributeEngine: not enough memory;BwPopMerge pop1(setIsLastMerge(1)),in executor::Executor in cube: p03_zxmsc01
    Can anyone tell me the solution for the above error. Or if there is a workaround to our requirement.
    Regards,
    Sachin

    Hi,
    Could be a memory issue.
    One of your cube in on BIA which is causing the Problem.
    So executing the query in RSRT by selecting Do not use BIA index option.
    If the query is executed with out any issue then take the cube out of BIA and push it back.
    Hope it helps.
    Regards,
    Raghu
    P.S : Also please let us know if this query is live and it is an issue that you are facing after executing it properly for few days.
    Or this is a new query created and testing now and in the process got this error?
    Edited by: Raghu tej harish reddy on Sep 24, 2009 5:53 AM

  • BEx Formula Use of 'Logical And' and Calculation for Gross Margin

    HI Bex gurus.
    Having an odd time with what should be a simple formula to handle the display of gross margin (GM). The goal here is to display GM% properly and the requirement is as follows
    If GM <= 0 then 0.0
      Else
    If GM > 0 and Sell > 0 then ( ( sell - cost /sell ) * 100 )
      Else
    If GM >0 and Sell = 0 then 100
    I am familiar with bex formulas and have referenced the help docs on booleans here -
    Boolean Operators - SAP Business Explorer - SAP Library
    But what is odd is that if I use a calculation or a CFK in the IF, THEN with a LOGICAL AND, the formula does not report correctly
    If I put in a static value, like 77, the expected logic is followed.  I have tried making sure have extra parentheses and changing the order of the statement, to no avail!  I could use some extra brains on this puzzling matter, so you help is greatly appreciated and will award points!
    Thanks
    lee lewis
    Here are the formulas in text and below screen shots.  Wish could copy and past formulas to and from editor!
    GM%77
    ( ( ( 'Order GM' >0 ) AND ( Order Sell  >  0 ) ) == 1) * 77 + ( ( ( 'Order GM'> 0 ) AND ( Order Sell == 0 ) ) == 1) * 100 + ('Order GM' <= 0) *0.0
    GM%
    ( ( ( 'Order GM' >0 ) AND ( Order Sell  >  0 ) ) == 1) * 'REF GM%' + ( ( ( 'Order GM' > 0 ) AND ( Order Sell == 0 ) ) == 1) * 100 + ('Order GM' <= 0) *0.0
    'REF GM%
    (order  sell - order cost /order sell ) * 100 )
    GM%77
    GM%

    Shouldn't you change on of the brackets in your REF GM% ?
    'REF GM%
    (order  sell - order cost /order sell ) * 100 )
    I would put that as
    'REF GM%
    (order  sell - order cost) /order sell  * 100 )
    Not sure what you mean with those red arrows... but in both cases you would be dividing by 0 (order sell = 0).

  • Calculations Translation- Bex vs Transformation

    Hello gurus,
    here is the line that I d like to translate in BW, and I d like to know what's the better way of implementing it in BW, is it in Transformation (formula/calculation), or in Bex.
    result = (1/3) x (sum of prior 3 month balance from date entered) x (number of days in the past 3 months) / (sum of prior 3 month sales)
    Assumption is that user 's input is 1 Month period. (please write the line in abap if you re thinking that it is easier).
    Thanks,

    Hey Suhas,
    i have this code below, but  I am the call fm get days in Month return 0, what do you think is the problem?
    (i am operning a new thread although it is a continuation for this one here:
    Customer Variable to return number of days previous months )
    DATA: l_s_range TYPE rsr_s_rangesid.
    Data: noOfdays type i,
          date_prev1 type /OSP/DT_DATE, date_prev2 type /OSP/DT_DATE,
          date_prev3 type /OSP/DT_DATE,
          var_yr type n length 4,
          var_mth type n length 2, var_mnth_prev1 type n length 2,
          var_mnth_prev2 type n length 2, var_mnth_prev3 type n length 2,
          var_day type n length 2,
          ev_days_prev1 type /OSP/DT_DAY,
          ev_days_prev2 type /OSP/DT_DAY,
          ev_days_prev3 type /OSP/DT_DAY,
          I_NUM_DAY type n length 2,
          loc_var_range LIKE rrrangeexit.
    CASE i_vnam.
    WHEN 'Z_F_RETURN_3MONTH_DAYS'.
      IF i_step = 2.
        LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZC_PERIOD_SR'.
        CLEAR: var_mth, var_yr, var_mnth_prev1, var_mnth_prev2, var_mnth_prev3.
        CLEAR: date_prev1, date_prev2, date_prev3, ev_days_prev1, ev_days_prev2, ev_days_prev3.
        var_mth = loc_var_range-low+5(2).
        var_yr = loc_var_range-low+0(4).
        var_mnth_prev1 = var_mth - 1.
        concatenate var_mnth_prev1 '01' var_yr into date_prev1.
       var_mnth_prev2 = var_mth - 2.
       concatenate var_mnth_prev2 '01' var_yr into date_prev2.
       var_mnth_prev3 = var_mth - 3.
       concatenate var_mnth_prev3 '01' var_yr into date_prev3.
        CALL Function '/OSP/GET_DAYS_IN_MONTH'
        exporting IV_DATE = date_prev1
        importing EV_DAYS = ev_days_prev1.
        I_NUM_DAY = ev_days_prev1.
       CALL Function '/OSP/GET_DAYS_IN_MONTH'
      exporting IV_DATE = date_prev2
       importing EV_DAYS = ev_days_prev2.
       CALL Function '/OSP/GET_DAYS_IN_MONTH'
      exporting IV_DATE = date_prev3
       importing EV_DAYS = ev_days_prev3.
        noOfdays = ev_days_prev1 + ev_days_prev3 + ev_days_prev3.
        l_s_range-low  = noOfdays.
        l_s_range-sign = 'I'.
        l_s_range-opt  = 'EQ'.
        append l_s_range to e_t_range.
        ENDLOOP.
      ENDIF.
    ENDCASE.

  • Calculation in BEx on Hierarchy Link Nodes

    Hello everyone. I am working on a BEx query that involves a hierarchy based on Controlling Area, Cost Center, and Cost Element. There is a case where I have 5 Cost Elements that belong to 2 Cost Centers. I can successfully create the duplicate nodes at the different Cost Center levels and activate the hierarchy. Where I am having difficulty is assigning a percentage factor to the key-figure at the parent-node (80%) and the link-node (20%). The high-level node at CO_AREA is correct. However, the COST_CENTER nodes show the total original value. I would like to apply these factors dynamically in the BEx query. I have tried structures and cell definitions and was able to apply the 80% and 20% factors correctly to the corresponding hierarchy nodes. Unfortunately, the amounts are not broken down as I would like to see them.
    I have looked at the documentation on "Link Nodes" and "Modeling Nodes and Leaves: at help.sap.com.
    http://help.sap.com/saphelp_nw04/helpdata/en/b3/fa3d3806136268e10000009b38f8cf/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/80/1a6743e07211d2acb80000e829fbfe/content.htm
    This is from one of the above links:
    "For both duplicate leaves and leaves in subtrees under link nodes, the values of the duplicate leaves are only considered once by the system internally. When aggregating, the system automatically calculates what are called correction leaves for the superordinate node.
    If a leaf Lo lies three times amongst the descendants of a node No, the value is added three times internally and then subtracted twice by the ’correction node’."
    I'm wondering if it is even possible to do what I would like to accomplish.
    I would appreciate any feedback and suggestions on how to solve this issue if you have done something similar.
    Best Regards,
    Albert Pecoraro
    Sr.SAP BW Specialist
    Ferro Corporation
    Example:
    CO_AREA_1000 = Total = <u><b>$1000</b></u> (AAAA = $800, BBBB = $200)
    --><u><b>COST_CENTER_AAAA</b></u> = $1000 @ 80% = <u><b>$800</b></u>
    >COST_ELEMENT_100 = 100 @ 80% = $80
    >COST_ELEMENT_101 = 200 @ 80% = $160
    >COST_ELEMENT_102 = 300 @ 80% = $240
    >COST_ELEMENT_103 = 150 @ 80% = $120
    >COST_ELEMENT_104 = 250 @ 80% = $200
    --><u><b>COST_CENTER_BBBB</b></u> = $1000 @ 20% = <u><b>$200</b></u>
    >COST_ELEMENT_100 = 100 @ 20% = $20
    >COST_ELEMENT_101 = 200 @ 20% = $40
    >COST_ELEMENT_102 = 300 @ 20% = $60
    >COST_ELEMENT_103 = 150 @ 20% = $30
    >COST_ELEMENT_104 = 250 @ 20% = $50

    Hi Alberto,
    Would you please post the resolution of the issue with the hierarchy node calculation? I too have a simillar requirement. It would be helpful if you share the solution for tha issue that you had.
    Saravana

  • Calculated Key Figures Corrupted in a BEX Query

    Hello SDN's,
    We are facing an weird issue in BEX Query. As part of Enhancing the query, We have created a new CKF and added in the Columns for the required CKF. It prompted for a Transport request and saved the Query elements for more than hour. Now the Query is throwing an Error messages where in more than some 30 CKF's got corrupted. When i check the CKF definition for all the corrupted key figures there is not Formula or Calculation.
    Below is the message which we can see in the BEX query for Corrupted Calculate Key Figure.
    Diagnosis
    Element ' XXX ' cannot be analyzed by the analytic engine without a definition.
    System Response
    Without a valid definition, the element will be ignored by the analytic engine.
    Procedure
    Provide a valid definition for element 'XXX'.
    Could anyone please help me to retrieve query back to normal ???. Your are inputs are appreciated
    Thanks,
    HA

    yo could try rsrt in bw and try to regenrate the query thats all i got. .otherwise always make a copy before you start working on a query. if it still is coruupted then you will have to recrate it. if the query is in your bwq maybe the basis can do a transport( not recomended)back. good luck..

Maybe you are looking for

  • How do I delete itunes library and move library from old windows machine to

    My daughter bought a new macbook and would like to move her itunes library from the windows machine to the mac. I copied it to the mac and moved the existing itunes folder to the trash. By the way, she got 3 free downloads from Apple and they were in

  • Photos app gets stuck "downloading" and doesn't update

    I uploaded my entire photo library to iCloud and once it was showing on all my devices, i added it to my macbook air. the issue I'm having is that it loads 543 pictures (out of 24,559) and stops, nothing else happens and i have left the laptop "ON" f

  • IMPORT Options in ITUNES:Settings,+16-bit OR 8 Bit??

    I have been importing my store-bought CD's into my ITUNES,..IMPORT SETTINGS>>>>>>>> there are several selections, *AIFF(my favorite),(as I want full, ROBUST-sound (I have the computer space...... *MP3, or *WAV or *Losless... trouble is..I'm getting c

  • Parametric Role

    I read about Parametric Role in OBPM Studio Guide,but did not understand. Can any one tell me more about Parametric Role with a good example. It will be good if any one share small BPM Project which uses Parametric Role.

  • ITunes 12 - Sort Show Option Missing

    Upgraded to iTunes 12 and when accessing a song under 'Sorting' the 'Sort Show' option is not listed.  But the 'Sort Show' option is available in the column browser.  I use 'Sort Show' to categorize songs into Smart Playlists.  How can I get this opt