Key Figure Calculation in Transformation

Hi Experts,
I have what seems like a relatively simple question however I cannot figure out the solution at the moment.  I was hoping someone shed some light on the situation.
I am loading line item detailed information into a DSO with various key figures.  I am loading quota type information into the DSO and need to sum the amount key figure if a specific quota type exists.  For instance:
Quota Type: 16
Amount: 15
Quota Type: 14
Amount: 5
If an employee has a Quota Type 14 then the Amount value of Quota Type 16 should equal 20 given the values above. 
What is the easiest way to write this formula/routine?  I was thinking this had to be done in a routine. 
Thanks,
DC

Hi,
If I have understood your requirement correctly ......
What we can do in such a scenario is ......
1. Make two restricted key fig. in Query designer ..... One for   amount(16) and the other for amount(14)........
2. Set display mode as 'HIDE' for both of them.... so that we cannot see them in the query output....
3. Now, make a calculated key fig. and add these two restricted key figs.
4. This new calculated key fig. will give us the desired result subject to the condition that other characteristics are same .....
I dont think we need to write any code here ......
Hope it helps ....
Please award points if it helps .....
Regards
Anshul

Similar Messages

  • Key Figure Calculation in Query

    Gurus,
    How do i calcculate below  in query  basically i have 3 KF as dates below and want a CKF or formula variable
    which calculates A - (IF B Not Empty then take B  or else take C.)
    Z = A - if (B != " '', B, C)
    A = Key Figure
    B = Key Figure
    C = Key Figure
    thanks

    HI Zuben,
    To acheive this
    calculates A - (IF B Not Empty then take B or else take C.)
    Z = A - if (B != " '', B, C)
    A = Key Figure
    B = Key Figure
    C = Key Figure
    Try this !!!!!!!
    If u create a  CKF,u will have operators in it,in that choose Boolean Operators,again in that chose
    1)is not equal to
    and
    2)Equal to.
    for ur calculations.
    Z= Calculated Key Figure.
    Z= A - (B NE 0)B + ( B EQ 0)C
    Case One -- B NE 0
    Z= A-(1 * B)+0
    Z = A-B
    Case Two -- B EQ 0
    Z= A-(0 * B)+(1*C)
    Z = A-C
    I guess this is your requirement.
    Rgds
    SVU

  • Key Figure calculation in Abap is not working correctly - Overlooping

    Hi,
    I wrote a logic to calculate the ratio of key figure but it is not working correctly
    For example I have a requirement to split 1 Product into Several new Products and also the Net Amount will be splitted to these several new products as well. The total Amount of the new product will be equivalent to the Net Amount.
    So far my Logic is splitting the product to several new products but the amount is incorrect as the calculation is over looping.
    Sample
    A PRODUCT has Net Amount 1000. And this product needs to be splitted into 3 new products. Each of this new product is assigned a ratio of 0.3, 0.2 and 0.7 respectively. total sum of the ratio is 1.
    PRODUCT1 0.3 = 1000 * 0.3 = 300
    PRODUCT2 0.2 = 1000 * 0.2 = 200
    PRODUCT3 0.7 = 1000 * 0.7 = 700
    The total amount of this new products is 1000.
    Now my logic is working this way.
    PRODUCT1 0.3 = 1000 * 0.3 = 300
    PRODUCT2 0.2 = 1000 * 0.2 * 0.3 = 60
    PRODUCT3 0.7 = 1000 * 0.2 * 0.3 * 0.7 = 42
    Only the PRODUCT1 is working correctly and there is overlooping for the remaining products
    Logic used
    DATA: t_data TYPE data_package_structure OCCURS 0 WITH HEADER LINE.
    DATA: t_newdso LIKE /bic/newdso OCCURS 0 WITH HEADER LINE.
    DATA: t_olddso LIKE /bic/olddso OCCURS 0 WITH HEADER LINE.
    DATA: amount LIKE data_package-netamount.
    DATA: zidx LIKE sy-tabix.
    REFRESH t_data.
    LOOP AT data_package.
      zidx = sy-tabix.
      MOVE-CORRESPONDING data_package TO t_data.
      REFRESH t_newdso.
      SELECT * FROM newdso INTO TABLE t_newdso WHERE prod =
      data_package-prod.
      SORT t_newdso BY prod.
    *LOOP AT T_NEWDSO.
      READ TABLE t_newdso WITH KEY prodh4 = t_data-prod.
      IF sy-subrc EQ 0.
        LOOP AT t_newdso.
          t_data-prod = t_newdso-/bic/znew_mp.
          t_data-material = t_newdso-material.
    *T_DATA-NETAMOUNT = T_DATA NETAMOUNT * T_NEWDSO-/BIC/ZSP_RATIO.*
          APPEND t_data.
        ENDLOOP.
      ELSE.
        REFRESH t_olddso.
        SELECT * FROM olddso INTO TABLE t_olddso WHERE prod =
        data_package-prod.
        SORT t_olddso BY prod.
        READ TABLE t_olddso WITH KEY prodh4 = t_data-prod.
        t_data-prod = t_olddso-prod.
        t_data-material = t_olddso-material.
        APPEND t_data.
      ENDIF.
      MODIFY data_package INDEX zidx.
    ENDLOOP.
    REFRESH data_package.
    data_package[] = t_data[].
    thanks
    Edited by: Matt on Sep 27, 2010 2:25 PM - added  tags

    Hi,
    I am not really good at debugging Abap code since I am a newbie. however  I have tried to add CLEAR T_DATA before the first loop.
    REFRESH T_DATA.
    LOOP AT DATA_PACKAGE.
    ZIDX = SY-TABIX.
    MOVE-CORRESPONDING DATA_PACKAGE TO T_DATA.
    and before the second loop and select statement and at the end of the loop.
    REFRESH T_NEWDSO.
    SELECT * FROM NEWDSO INTO table T_NEWDSO WHERE PROD =
    DATA_PACKAGE-PROD.
    SORT T_NEWDSO BY PROD.
    READ TABLE T_NEWDSO WITH KEY PROD = T_DATA-PROD.
    IF sy-subrc EQ 0.
    LOOP AT T_NEWDSO.
    but then not all data are being fetched.
    thanks
    Edited by: Bhat Vaidya on Sep 28, 2010 8:33 AM

  • Use of Key Date in Virtual Key Figure Calculation

    I have a virtual key figure whose value depends in part on the key date entered by the user.  I have the VKF set up with a dummy calculation, and it is working OK.
    How do I refer to the value of the key date in the code that assigns the VKF value?
    Thanks,
    DP

    Found the answer, thanks to another thread:
    Function RRS_VAR_VALUE_FROM_MEMORY_GET with I_VNAM equal to the key date variable returns the value of the key date.
    DP

  • Query key figures calculation issue

    Dear Sap Gurus,
    I would like to calculate the sum of one key figure on the month m-3 m-2 and m-1
    I have created 3 restricted key figures filtered by month m-3, m-2 and m-1
    i have created a key figures one which one I sum these 3 key figures but the result per month is not egal to the summation but to the value per month
    on the example below
    one this field is what i have D- Sum Other Requirements
    one this field is what i would like to have Sum Other Requirement Past
    Thanks for your answer
    Calendar Year/Month     janv-07     FEB 2007     mars-07
    D- Other Requirements month-6     69,888 PC          
    D- Other Requirements month-5          281,385 PC     
    D- Other Requirements month-4               19,854 PC
    D- Sum Other Requirements     69,888 PC     281,385 PC     19,854 PC
    Sum Other Requirement Past     69,888 PC     351,273 PC     371,127 PC

    Hi,
    Create one RKF based on your key figure,
    go t property of RKF and mark constant selection.
    now in this field you can see the sum of key figure field.
    and you can use it for formula.
    Hope it help you.
    Regards
    Suneet

  • Calculated key figures Vs local formula

    HI,
    I am having 4 queries on a cube.
    i am now using calculated key figures instead of local formulae.
    I want to know "which is better in performance wise/ or may be pros and cons of using each one."
    Can any one clarify me.
    I know that
    1.when we select the option Calculation after aggregation will improve performance.
    2.we can do some more things only with Cal. Key Figs using formula variable.
    Here my concern is not that.
    I am concerned about general case like -
    i have to add, multiply or divide some direct key figures and use some data functions like nodim, NDIV0 functions.
    Thanks in advance.
    Regards,
    Raghu

    Hi Raghu,
    Formulas cannot be directly reused, but if they are saved to a global structure, then the structure may be reused. If you are creating a calculation that will be widely used, it is best to create it as global...this helps a lot when you need to revisit the definition, and make changes as one chnage is reflected in all queries.
    However, there are some functions like SUMCT, SUMGT, SUMRT, %CT, %GT, %RT which are available only to the formulas (local), so if you need to use them, you cannot use a CKF.
    In addition to the differences, A formula can only work on other formulas/selections already in your query (in the same structure as your new formula), while a calculated key figure can only work on other key figures, calculated key figures or restricted key figures. However both can use formula variables.
    CKF are calculated at the time of loading data.
    Your Formula calculates at the time of running the query.
    Hope this helps...
    Regards,
    Yokesh.

  • Diff between Calculated key figure and new formula 6extra functions why

    Hi Friends
                  In BEx query designer we have Restricted key figure & Calculated key figure. In the case of Ristricted Key figure And new selection the difference is Global and local.
    But if we come to Calculated Key figure and New Formula the difference is same global and local. But in New formula we have 6 extra function. My question is does is there any certain reason for this or SAP AG not be able to develop those functions
    Thganks & Regards
    Bramhanand

    Hi Surendra thank you for your reply.
    But i am not asking difference between calculated key figure and New formula.
    What i am asking is in the case of Restricted Key figure And new selection the difference is Global and local.
    But in Calculated Key figure and New Formula the difference is same global and local and in New formula we have 6 extra function. My question is does is there any certain reason for this.Why not SAP AG is not included the new formula functions in Calculated key figure.
    Thanks & Regards
    Bramhanand

  • Calculate key figures totals in report based in multiprovider doesn't work.

    Hi dear Friends:
    We have a requirement where the data are in 2 different cubes, the layout defined is
    selections parameters :
    Zsales_offices
    0calweek
                   Columns.
                   0calweek  KFCalc1..............................KFcalc2.....................etc.
                   In rows.
                   01.2007   Qty on demand X unit cost.    sum of all qty's prods
                   02.2007
                   03.2007
                   04.2007
    the structure in cube z1mis contain:
    Zsales_offices,product,0calweeek,unit cost.
    the Second cube structure zdemand contain:
    Zsales_office, product,0calweek,qty on demand
    Our problem is:
    1. As you can see we need keep into KFcalc1 the product from multiply Qty on demand * unit cost but when the result is displaying the result is a wrong amount and the reason is because didn't´t exist a characteristic product in the layout, without this characteristic the amount for qty on demand and unit cost are summarized and multiplying with these amounts.
    We are trying to find a solution vía restricted key figures, calculating before aggregation, but it's not woks.
    I hope that you can give one suggestion.
    Regards.
    Eg@n

    Hi,
    putting product in the rows will slove the issues as the unit cost  depends upon the  prdoduct and therefore it will uniquely identify each of the material and then it will get multiplies with the qty and therefore you will get the correct result.
    this kind of issue you will always face when you are going to multiply cost with the Qty and as the cost differ with the individual material.
    Also putting material into the rows will cause the no. of rows to increase as all the materials will show up in the individual rows for the particular month.
    Also you can make a claculated key fgure for the multiplication and use before aggregation.
    But for that your both the key figures should be in the same cube i.e. in the same rows or the before aggregation will not work you will not even get an option of before aggregation in the CKF if the key figures belong to two different cubes.
    Since your qty and cost are coming from two different cubes before aggreagtion will not work here.
    And if you do before aggregation then you report will become quite slow as it will do all the multiplication anf then will bring the result.
    So it depends on your requirement and your design how to proceed.
    Hope it helps
    Thanks

  • Combine two reports in query designer using key figure with sap exit

    Hi experts,
    i want to combine two reports in query designer using key figure with sap exit
    in the report 1 key figure calculation based on the open on key date(0P_DATE_OPEN)
    to calculate due and not due in two columns
    in report 2 key figure calculate in the time zones using given in variable Grid Width (0DPM_BV0) like due in 1 to 30 days, 31 to 60 days...the due amount based on the open on key date(0P_DATE_OPEN)
    to calculate in 1-30, 31-60, 61-90, 91-120, 121-150 and >150 days in 6 columns
    now i have requirement like this
    not due, 1-30, 31-60, >60, due,1-30, 31-60, >60 in 8 columns
    or
    not due, due, 1-30, 31-60, 61-90, 91-120, 121-150 and >150 in 8 col
    thank you

    Hi Dirk,
    you perhaps know my requirement,
    for the management to make used in one report,
    we have in reporting finacials Ehp3.
    Vendor Due Date Analysis - which show due, not due
    Vendor Overdue Analysis - show only due and analysis in time grid frame
    i want to combine in one report that show NOT DUE, DUE, DUE time frames in grid.
    krish...

  • New Restringed key figure

    Hi experts!
    We would like to ask if it is possible to create a new calculated key figure within an BEX report in this way.
    If the key figure is between a range of two key figures calculated, we would like to make it have a value in letters.
    For example, we have the KF 1 with value and the KF 2.
         We would like to have two new key figures having into account KF1.
              If the difference of Key figure is +/- 1, we would like to see a value (ideally in text)
              If the difference of that key figure is supeior to 1, we would like to see other value (ideally in text)
         The the idea is: ¡
              KF3 =>If the value of KF1 is between +2 / -2 over KF2 ==> Value "OK"
                        KF 1 = 10
                        KF 2 = 10,5
                        Range (-1,+1)
                        As result => KF3 with value " OK"
              KF4 => If the value of KF1 is superior +2 / -2 over KF2 ==> Value " NO OK"
                   For example:
                        KF 1 = 10
                        KF 2 = 14
                        Range (-1,+1)
                        As result => KF4 with value "NO OK"
    In case that text is not possible, do you see any other alternative?
    Thank you very much in advance for your help!!

    Hi DieGasse,
    create two restricted KF with the above logic which you have mentioned.
    and then follow the below procedure
    1) click on the exception button in the tool bar
    2) you will get separate tab 'exceptions' .
    Rclick on the area, and click 'create exception'.
    3)Rclick edit --> New
    4)select Good(green)/average(yellow)/bad(red) and the values.
    5)in the definition tab of your exceptions, select your keyfigures
    6)save and activate the same
    let me know if you need more help in this.
    BR
    adlin

  • Restricted key figure

    HI,
    can any body explain me what is the difference between Restricted key Figure and the filter option in BEX reporting.

    Hi Ali,
    If you want restrict particuler key figure based on characteristic value, that you have to go for restricted key figure.
    For example: You have calender year month data from 2005 to 2006.An dyou have also have sales data for the period.
    If you want see the say some feb 2005 to may 2006.
    than you can use restricted key figure to see the values.
    where as Filter will show the values which you have filtered irrespective of key figure (only characteristic value).
    just go throw the below description.
    Hi,
    Restricted key figure:
    Use
    You can restrict the key figures of an InfoProvider for reuse by selecting one or more characteristics. The key figures that are restricted by one or more characteristic selections can be basic key figures, calculated key figures, or key figures that are already restricted.
    Procedure
    Defining a new restricted key figure
    1. In the InfoProvider screen area, select the Key Figures entry and choose New Restricted Key Figure from the context menu (secondary mouse button).
    If a restricted key figure has already been defined for this InfoProvider, you can also select the Restricted Key Figures entry and then choose New Restricted Key Figure from the context menu.
    The entry New Restricted Key Figure is inserted and the properties for the restricted key figure are displayed in the Properties screen area.
    2. Select the New Restricted Key Figure entry and choose Edit from the context menu (secondary mouse button.
    The Change Restricted Key Figure dialog box appears.
    You can also call the Change Restricted Key Figure dialog box from the Properties screen area by choosing the Edit pushbutton.
    Calculated key figure:
    Use
    In the Query Designer, you use formulas to recalculate the key figures in an InfoProvider so that you can reuse them. Calculated key figures consist of formula definitions containing basic key figures, restricted key figures or precalculated key figures.
    Procedure
    Defining a New Calculated Key Figure
    1. In the InfoProvider screen area, select the Key Figures entry and from the context menu (secondary mouse button click), choose New Calculated Key Figure.
    If a calculated key figure has already been defined for this InfoProvider, you can select the Calculated Key Figures entry and, from the context menu, choose New Calculated Key Figure.
    The system adds the New Calculated Key Figure entry. The properties for the calculated key figure are displayed in the Properties screen area.
    2. Select the New Calculated Key Figure entry and, from the context menu (secondary mouse button), choose Edit.
    The Calculated Key Figure dialog box appears.
    You can also call the Change Calculated Key Figure dialog box from the Properties screen area by choosing the Edit pushbutton.
    Formula:
    Use
    You can recalculate the key figures in a structure using a formula. You can include basic key figures, restricted key figures, and calculated key figures in the formula definition.
    Procedure
    Defining a Formula
    1. If the query does not yet have a key figure structure, create a New Structure in the Rows or Columns of the Query Designer by highlighting the row or column directory using the secondary mouse button and selecting New Structure from the context menu.
    2. If the structure does not yet contain any key figures, use drag and drop to transfer a (basic) key figure of the InfoProvider into the directory of the new structure.
    3. Select the structure directory, and choose New Formula. The New Formula entry is inserted and the properties for the formula are displayed in the Properties screen area.
    4. Select the New Formula entry and, from the context menu (secondary mouse button), choose Edit. The Change Formula dialog box appears.
    You can also call the Change Formula dialog box from the Properties screen area by choosing the Edit pushbutton.
    Regards,
    Shailaja

  • Can we do caluculated keyfigure with in a restricted key figure

    can we do caluculated keyfigure with in a restricted key figure give details

    Hi,
    Calculated key figures consist of formula definitions containing basic key figures, restricted key figures or precalculated key figures.
    The key figures that are restricted by one or more characteristic selections can be basic key figures, calculated key figures or key figures that are already restricted.
    For more help go to these links,
    http://help.sap.com/saphelp_nw04s/helpdata/en/61/d0b143aa26b849b4e79a859ea1d7d1/content.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/13/e072abaddb574284d22361f0b824bf/content.htm
    assign points if it helps
    Thanks & Regards,
    santo

  • The use of restricted key figures in real time scenario

    Hi all,
    Please let me know the use of restricted key figures in real-time business scenarios....plz someone explain it with <b><u>example</u></b>...
    Also, can restricted keys be defined globally with same infoprovider...???????????
    Your response is thankfully acknowledged,
    thanks and regards,
    shalini.

    Hi,
    You can restrict the key figures of an InfoProvider for reuse by selecting one of more characteristics. The key figures that are restricted by one or more characteristic selections can be basic key figures, calculated key figures or key figures that are already restricted. Which means you can define and use them globally in reporting for a particular infoprovider.
    Example:
    You have to show the sales for different product typessay 1, 2, 3, 4, 5, 6, for a company code.
    now you can define a RKF with company code and sales keyfigure.
    In the report, in columns, you use this RKF in new selection and restrict it with product type in 6 diff columns.
    New Selection.
    Restrict it with RKF
    Restrict it with product type 1.
    similarly for others..
    Hope this helps you....

  • 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]

  • ELSEIF in calculated key figure

    Dear gurus
    We have recently upgraded to NW2004s, and would need some help on the formula for my calculated key figure. This calculated key figure is meant to replicate IF... ELSEIF statement, depending on what the user enters. The logic that we have are as below :
    IF Var=1, then display key figure A
    ELSEIF Var=2, then display key figure B
    ELSEIF Var=3, then display key figure C
    ELSEIF Var=4, then display key figure D
    where Var is a Formula Variable, Processing By User Entry/Default value.
    The formula that we have originally, in BW3.5 is :
    <i>(Var == 1) * 'Amount in TC' + (Var== 2) * 'Amount in Comp Code' + (Var == 3) * 'Amount in Parall USD' + (Var == 4) * 'Amount in Hard Cur' </i>
    This formula has served us well in BW 3.1 to BW 3.5, and never had any problems with it. However, when we migrated over to BW 7.0, we could not get values for this formula (eventhough we have data in our cubes). The only data that get is when we key in Var=1, but when we try with Var=2, 3 or 4, no data is displayed in our key figure.
    We tried to debug, but somehow we could not figure out how the new BW7.0 calculates these type of key figures, and whether is there a change in the formula variable. We believe that the problem may lie in the way that BW 7.0 interprets the formula above, and only obtains the first portion of the formula (Var==1).
    We would appreciate any helps, and of course, points will be awarded if problem can be solved.
    Thanks a lot

    Dear all
    With some luck in searching, I manage to find an OSS note which depicts this error and resolve it. For those who have the same problem, please use this OSS Note 994194.
    Cheers

Maybe you are looking for

  • Error in PO Print Preview

    Hi , We have a PO with line items 10,20 which was sent to vendor ,the PO received by the vendor shows now both  line item 10,20 and now the vendor has delivered goods. After some time, when we add new line item 30 to the same PO, and when PO is sent

  • Layout in Arabic, Russian and Chinese. Exporting text from a PDF

    I am laying out long documents in Arabic, Russian and Chinese. The text has been provided as a PDF when I copy and paste this into Indesign it comes up as boxes question marks and other characters having nothing to do with the text I am trying to lay

  • When opening an image in Adobe Camera Raw in CC, the image is solid red

    The image is solid red and not my image. I have been working on an image and several layers of work done on things like white balance, color cast.  When I add a CAL I cant get to ACR at all. If im on the previous CAL I can open in ACR but with the re

  • Video out on iPod touch 2nd Gen - with dock?

    Hi, So apparently you can watch videos on your tv if you buy the universal dock for iPod touch 2nd Gen? How does it work and do you get RCA cables with the dock or do you need to purchase them separately? Does the dock come with the USB cable or is t

  • Array of cluster color change

    I have an array of clusters that I'd like to change the color of each cluster programatically. I've attached the cluster hoping for some help. I'd also like to be able to disable some clusters while enabling others. Is this possible? is there a bette