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

Similar Messages

  • Problem with virtual Key Figure in a query

    Hi Experts,
    I would like to share my problem with the virtual key figure in a query:
    I have a query with a virtual key figure and when I eject the query by analyzer, the result sometimes is displayed and sometimes is not displayed (is equal to 0), with the same initials values. And when I eject the query by RSRT always display the result for the virtual key figure.
    Why don't always display the result?
    Thanks a lot

    Hi,
    I think that the problem is the level of support package. We have BI AddOn 7.X (based on 7.20) support package 0.
    What do you think?
    Regards

  • Changing the formula to a key figure on a query

    Hello All,
    I do not have access to BEx. I would please like to know how to change the formula to a key figure "Total $" in a QD Promo Analysis query (technical name - N03_Q_D_N03_SD_502_0003). Will transaction RSRT take me to the query and eventually the formula so I can change it? If so please give me guidance as this is the first time I go into transaction RSRT. If there is another way please also give guidance.
    Thank you and kind regards
    Keith Kibuuka

    Hi Vishvesh,
    Thank you for your response. Maybe access to BEx was the wrong word - I do have access although I was trying to avoid configuring the SAP logon to add this particular client onto because I have not done this before. My boss has helped me and I have now have "access".
    Therefore from the query designer can you please guide me on how to change the formula to a key figure on a query? Input from all people is also be very much appreciated.
    Thank you and kind regards,
    Keith

  • 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

  • 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

  • Lock key figure with a query

    Hi BW gurus,
    I have created a calculate key figure 'CKF1' in the development system and added to a query 'Q1'. The same calculated key figure is presnt in the production system and is being used by some queries.
    As we know that BW handles the duplicate calculate key figures on its own. However, to transport Q1 and CFK1, the system requires that SFK1 should be locked by/for Q1. I need help in doing that.
    One liner: How to lock CKF1 with Q1?
    Thanks.

    Hi Anooj,
    this is my understanding :: u made  ckf1 as global.if u make it as a local  then other queries can't use this.
    regards
    sridhar

  • 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

  • Sort Key Figure in a Query

    I have a situation where I have to use a query (not possible to use a view - long story, but limitations on views make it so)
    I have a simple query that has products on rows, and Month and Sales Value on the columns.
    I want to sort the Sales value descending.
    ie
    product   Sales Value/8.2005
    prod1      500
    prod2      400
    prod3      300
    How do I tell the query to sort on the Key figure value descending as shown above???
    I have managed to achieve this by putting a condition on that returns the top 100% of the query, however there must be a better way??? (although I am slowly losing confidence in SAP's thinking (or lack thereof))
    Thanks in advance for any assistance.
    Regards
    Richard

    Hi JKyle,
    Thanks for your response.
    I am aware that you could sort by using the Properties on the context menu of the key figure, but this is no good for a default view without hacking the URL, which becomes quite tedious. (My users are not capable of entering even the simplest of variables, let alone using a context menu to sort every time they run a report.
    You can also bookmark once it has been sorted, however have had problems with bookmarks disappearing in the past, and so I don't really consider this to be a solution either.
    I guess I thought that this was such a fundamental requirement that it would be included, and that I was missing some setting somewhere when developing the query.
    Thanks again for your response.

  • Exception color can not display at another key figure in BEx query desinger

    I have a report requirement, the user want to display the average price on each month ,such as:
    Jan.   Feb. Mar.  Apr. etc.
    100    105    104   95   ....
    and the user want to compare each other months with Jan's price.
    they want to display the exception color when the rise or down rate greater or less than 5%.
    Now ,I can only change the output structure such as:
    Jan.  Feb. Rate2-1                 Mar.  Rate3-1                 etc.
    100   105   (105-100)/100=5%  104    (104-100)/100=4%  ....
    Now I can set Exception on the formula Rate2-1 Rate3-1....
    But the Exception color can only display on Rate2-1,Rate3-1...
    and Not the Keyfigure Feb. Mar...
    I am using the BI 7.0 and the new Query Designer.
    Who can help me to solve this question .
    Thanks.
    Yours Youming.Zhao

    Hi,
    its simply not supported for BEx Analyzer. Exception reporting on another key figure is only possible for Web Reporting.
    Check this actual SAP Help Link:
    [Restrictions in the BEx Analyzer|http://help.sap.com/saphelp_nw70/helpdata/en/45/5038f28cce08d2e10000000a11466f/content.htm]
    Sorry that i dont have a better answer
    Cheers

  • 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

  • Convert characteristic values in key figures in a query

    Hello all,
    i have a query which provides some key figures and also some probabilties (defined as characteristics). I want to multiplicate the probabilities with the key figures and therefore I need to convert the characteristic values for the different probabilities in key figures.
    What is the best wys to do this.
    Any help would be great.
    Best Regards,
    Stefan from Munich/Germany

    Stefan,
    You need to create a formula variable of your characteristic.
    In the Create Formula screen right mouse click on Formula Variable and go through the create process.
    The characteristic needs to stay in your query (you can change it's display to No Display) to pass it's value to the formula.
    Once you have done this you can use the formula Variable in any other formula.
    Regards
    Gill

  • Number of key Figures used in Query

    Hi,
    I would like to know the number of queries in a Query,
    Is there any way to find out this?
    We have nearly 100 queries, and we were asked to find out the top 5 queries in terms of number of key figures.
    Thx.

    Hi Thejo,
    There is no direct way to do this using another BW query simply because the data is not stored in either Masterdata Info Objects/CUBE ODS. They are stored in BW system tables which are not directly accesible by any queries to build using the Query Builder.
    Try to locate the system table that holds these Info (Keyfigures + Query Name) and do ABAP Query instead.
    Regards,
    Jkyle

  • Key Figure Restrictions in Query

    Hi all,
    I've got this scenario on hand:
    I want to display a Bex report with the a particular key figure (Actuals) restricted to only specific value COMBINATIONS of two characteristics (Cost Centre and Cost Element). i.e. The restrictions should only apply for each individual combination of the characteristics (e.g for Cost centre = S0561 and Cost Element = 70400 , another combination could be for Cost Centre = S0352 and Cost Element = 70610 ).
    The challenge here is that if you restrict the key figure based on the individual characteristics (say, for Cost Centre = S0561 , S0352 and for Cost Element = 70400 , 70610) then it blocks off other figures from characteristic combinations that are should be allowed (e.g. Cost centre = S0561 and Cost Element = 70610 ,  and another combination of Cost Centre = S0352 and Cost Element = 70400).
    Any suggestions on how to handle this, typically from a previous experience, will be appreciated.
    Regards,
    Uche

    Hi Uche,
    A workaround for this scenario would be to include a hidden keyfigure for every characteristic combination. (If there are not many combinations)
    For e.g.
    Hidden KF1  Restricted on Cost centre = S0561 and Cost Element = 70400
    Hidden KF2  Restricted on Cost Centre = S0352 and Cost Element = 70610
    Then another final key figure, which is visible and is a formula KF
    Actuals     Formula = Hidden KF1 + Hidden KF2 + ..
    Best Regards,
    Dabre

  • Benchmarking Key Figures in a query which is posted in a web template.

    Hi All,
    has someone experiences with benchmarking in a query?
    What possibilitys do we have?
    We want to show the following:
    The query has in the rows the characteristic "sector" and in the collumns several figures. We navigate in this report via "filter and drilldown according to" to the next lower level. What we want to show is a benchmark of the figures of the lower level to the result of the first level. Example: The result of "sector1" is 150, "sector2 100" and so on and we navigate from sector1 to the belonging lower level "segment A, B, C, D". Now we want to see the information of the result of the filtered sector (150) as a benchmark to the associated segments A, B, C, D.
    I know it is a bit complicated but perhaps someone has a good idea for a solution?
    Regards
    Mirjam

    Have you found the solution? I have a similar kind of requirement.

  • Problem in display of char. and key figure for yearly query

    Hello all,
    I got a query in which i have to do restriction on
    Calendar Day/Month in Rows under Material which is a Characteristics
    So it should be
                                                               PACKAGE QUANTITY
                                            JAN  FEB  MAR   APRIL.......DEC
    PACK1
    PACK2
    PACK3
    PACK4 for current year
    PACK4 for prior YEar
    Now the months display is not pre decided, it can be anything as per the input of user.
    So i have to restrict it on Calendar month for Material twice
    In current year , just introducing the Interval range variable
    In previous year, same restricition with offset -12
    Now the problem is while displaying it shows
                                           JAN'06 JAN'07  FEB'06 FEB'07  MAR'06 MAR'07........ 
    PACK1
    PACK2
    PACK3
    PACK4 for current year
    PACK4 for prior YEar
    Which is not desirable.
    I only want value for Jan in one column
    and for previous year and current year in different rows thats it.
    If i remove Calendar year/month from columns there is no way I CAN DISPLAY MONTHS .
    How to achieve this.
    Please suggest.

    Kartikey,
    Rusty's suggestion wont work - using two characteristics for year and month will have the same effect as the position you are in at the moment.
    ie..
    2007     Jan.07     Feb.07    Mar.07   Apr.07
    2006 -
    Jan 06  Feb 06  Mar 06
    If you have the posting period of 01 - 02 - 03  (just the period number only, no year) then your query will display
    2007-01-02-03-04
    2006-01-02-03-04
    Regards
    Gill

Maybe you are looking for