Calculated KeyFigure Formula

Hi All,
I would like to write some code in Calculated KeyFigure Formula,
I have checked the forums. pls donot include SAP Help URL's.
Pls explain, if it is possible to write the code...
Best Regards,
Pandu.

Well, not sure if you saw the info here: http://help.sap.com/saphelp_nw04/helpdata/en/23/17f13a2f160f28e10000000a114084/content.htm
But you can create the IF THEN by using ( ) in the forumla builder:
Reqt: IF A > B THEN B + C ELSE A
Formula: (A > B )* (B + C) + (A <= B ) * A
Each expression in the ( ) is evaluated as True or False and accordingly outputs 1 or 0.
Hope this helps...

Similar Messages

  • Bex Query- Use of ABAP code in Calculated Keyfigure/formula

    Dear Experts.
    I am wondering if there is any way to use ABAP in the formula editor of the Bex Query desinger.
    I have to build a report with very complex formulas (a lot of key figures, comporations, If then else ) an I think it would be easier to build all then in ABAP.
    So what I am looking for is any kind of user-exit/Badi that allows to calculate a Calculated Key figure/fomula in ABAP with the same data that is availabe in the fomula editor.
    If SAP is not providing this, this is clearlly a must for next releases.
    Thanks a lot and best regards,
    Alfonso.

    Dear Ananda.
    Thnaks for your reply, but could you please extend your answer a little bit more?
    As far as I know, Formula customer exit variables are only called once and they don´t provide the rest of the keyfigures and characteristic use in the drilldown level, so for my needs they are useless.
    Regarding IF-then-else statement in the formula, I already know about it. Actually what I am trying to avoid is to use them. In order to build my query I might need to build really big formulas with a lot of If-then-else, making it quite complex what the formula is doing. This is the reson I want to do it on ABAP.
    Please any other ideas?
    Thanks a lot.

  • Condition for Calculated KeyFigure

    Hi everyone,
                          I need to have an additional Keyfigure based on a Condition. For example, If  Staus is Completed , then I need to take  the Net Price as Allocated Price. And if Status is Incomplete , then I need to fill the Net Price as UnAllocated Price.
    So , in this case , I will have 2 Calculated KeyFigures in the Query Designer. One for Allocated Price and the other for Unallocated Price. But how can I restrict t the values based on Status.
    For Example
    Status            Net Price       Allocated Price      UnAllocated Prcie
    Complete          100                   100                       0
    InComplete        200                   0                          200
    1) Is there any way tht  we can avoid displaying Unallocated Price for Complete Status(Since value will be Zero) and Allocated Price for Incomplete Status
    2)Is it better to have these values calculated in END ROutine in the BackEnd.(But this might affect the performance as I require these values only for this Report and I have more than 2 Reports based on the same InfoProvider)
    Thanks and Regards,
    Samir

    Hi,
    Could you please let us know what will be the value of the status field if it is incomplete. Suppose if you have an EMPTY value if it is not complete, you can use the IF ELSE condition with the Boolean operation in the Calculated Keyfigure or Formula as below,
    (Status ==1)* Unallocated Keyfigure + (Status NOT EQUAL 1)*allocated Keyfigure
    If it is not the case then better to handle it at the routine level. Hope this helps.
    Regards,
    Mani

  • %CT percentage function in Calculated Keyfigure missing

    Hai,
    I want to use the %CT percentage function in Calculated keyfigure.
    But I can only find % and %A function under the PERCENTAGE FUNCTION. Am using BW 3.5. Why is it so?
    Regards,
    Neha Solanki

    Hi neha,
    This will be not available in CK's u have to use formula to get this.. Just try to create the Formula in the querry instead of CK...
    Khaja

  • Effect of Restricted Keyfigure & calculated keyfigure in query performance

    Hi,
             What is the effect of Restricted Keyfigure & calculated keyfigure  in Query Performance?
    Regards
    Anil

    As compared to formulas that are evaluated during query execution, calculated key figures are pre-calculated and their definitions are stored in the metadata repository for reuse in queries. The incorporation of business metrics and key performance indicators as calculated key figures, such as gross profit and return on investment (which are frequently used, widely understood, and rarely changed), improve query performance and ensure that calculated key figures are reported consistently by different users. Note that this approach improves query runtime performance but slows InfoCube or ODS object update time. As a rule of thumb, if multiple and frequently used queries use the same formula to compute calculated fields, use calculated key figures instead of formulas.
    RKFs result in additional database processing and complexity in retrieving the query result and therefore should be avoided when possible.
    other than performance, there might be other considerations to determine which one of the options should be used.
    If the RKF's are query specific and not used anywhere in majority of other queries, I would go for structure selections. And from my personal exp, sometimes all the developers end up with so many RKF and CKF's that you get easily lost in the web and not to mention the duplication.
    if the same structure is needed widely across most of the queries, that might be a good idea to have global structure to be available across the provider, which might considerable cut down the development time.

  • Calculated Vs Formula

    Hi to all,
    Pls can anybody tell me whats the main difference b/w calculated keyfigures and formula?
    Thanks in Adv,
    MSM.

    Hi,
    Calculated Keyfigure is global (for all the queries for that Infocube/ODS) where as Formula is local(for that query only). CKF will have tech name and description where as Fomula will have only description.CKF is available across all Queries on same InfoProvider where as formula is available for only for that Query.
    For more information, pls check Re: query
    Regards,
    R.Ravi

  • Help needed in creating a calculated keyfigure/query exit

    Hi Reporting Gurus
    Please someone give me a solution for my issue.
    I have two keyfigures
    Plan Finish Date(PFD)
    Actual Finish Date(AFD)
    I have one calculated keyfigure
    Delivery Status = (AFD<=PFD) .  When this condition is met it returns ‘1’ else ‘0’.
    But Delivery Status = (AFD<=PFD)  returns ‘1’  if AFD and PFD both exists and if the condition is met and also works (returns ‘1’) for the scenarios mentioned  below.
    1.     if AFD is blank and PFD is filled
    2.     if AFD and PFD both is blank.
    So I need  a solution for my issue in such a way that
    Delivery Status = (AFD<=PFD)  should return ‘1’ only if AFD and PFD both exists and only if AFD<=PFD.
    For rest of all the scenarios my calculated keyfigure should return ‘0’ , i.e.,
    1.if AFD is blank and PFD is filled
    2.if AFD and PFD both is blank.
    3.if AFD is filled and PFD is blank.
    How to achieve this?
    Should I have to write a customer exit variable and incorporate ABAP codes or should I have to write VB macros or can we have a calculated keyfigure with a necessary logic or is there any other way to achieve it.
    Please help me out.
    Thanks in Advance,
    Have a nice day
    Regards
    Sam

    You can create a new calculated key figure which calculates the result which looks as follows...
    =  ((AFD<>0) AND (PFD<>0) AND (AFD<=PFD)) * 1 + 0
        Please check the syntax when done. You can refer to the below link for more info abt using IF ELSE operations in calculated keyfigures. Please let me know if you come across any issues.
    http://help.sap.com/saphelp_nw04/helpdata/en/23/17f13a2f160f28e10000000a114084/content.htm

  • Calculated keyfigures not defined correctly error when executing query

    Hi Experts,
    I changed calculations in the calculated keyfigures and saved successfully.
    when I execute the query in BI7 Bex, I am getting errors like query element not defined correctly in the query. when I look into query in the designer its giving info messages for many calculated keyfigures saying reusable and saving can influence other queries.
    I reverted back the changes but the errors still coming up. I tried to copy the query and run it ..still didnt helped..
    Please suggest me with the solution..
    Quick replies are much appreciated and awarded.
    Thanks
    Vanaja

    Hi,
    The calculated keyfigure is the difference of two other calculated keyfigures...
    I tried to re-drag and drop into keyfigures column and didn't worked and still getting the errors.
    Please suggest some more..
    Thanks
    Vanaja

  • Calculated Field formula not appearing in Power View Field List panel

    Hi,
    On Power View1 sheet of this
    workbook, the two PowerPivot calculated Field formulas (First Visit and First date of FY) are not appearing in the Power View Fields panel on the right hand side.
    I want to drag client and First Visit (calculated Field) to the Power View.
    Why is this happening?
    Regards, Ashish Mathur Microsoft Excel MVP www.ashishmathur.com

    I found a workaround for it - I was having the same problem as you. I wanted to display the last refresh date of my data, but Power View wouldn't display a date resulting from the [Last Refresh]=MAX(Date[Date]) formula.
    HOWEVER, a Pivot Table can handle that Calculated field just fine. So I renamed my measure "Refreshed Date" and added another tab in the Excel Sheet. I added a Pivot Table from PowerPivot into cell A1 and the only thing I put was that single
    measure (A2). To the right of that, I did =A2 and created an Excel Data Table. The title of that was "Last Refresh". Now, I could add that Data Table to the PowerPivot Model and into Power View. And then I hid that tab.
    The only downside to this method, is that if you're refreshing single tables at a time, you have to remember to refresh the Pivot Table when new data is added AND update the data in the model. I'm only connecting to one database, so I just choose
    "Refresh All" in Excel and it updates everything. It works perfectly! :)
    Well shoot, I even took a screenshot that helped explain everything, but it won't let me post it because my account isn't verified and it won't tell me how. If you have any questions, please let me know and I'll clarify!

  • Using result of a Calculated Keyfigure as input for a Virtual Keyfigure

    Hi experts,
    is it possible, to use the result of a calculated keyfigure of a query for the input of a virtual keyfigure und use the virtual keyfigure within the same query?
    My problem: depending on drilldown, I have a different percentage within the calculated keyfigure. And depending on that value, I would like to read a score out of a DSO and fill a virtual keyfigure with that, and show the score in the same query. In my opionion, the only way to calculate the score is on the fly, depending on the navigation step I do. Maybe there is another approach that I do not know.
    I was glad for any ideas. Thank you in advance!
    Regards
    F.L.

    Hi,
    Sorry but a calculated key figure result cannot be used in a virtual key figure calculation. The reason purely being that the CKF calculations happen after the Virtual KF/ Char calculations (through BAdI or CMOD).
    The only solution i see here is that you will need to do the calculations in the VKF logic itself. Please do remember that VKF calculations and population happens for each record bein fetched into OLAP from the Infoprovider for the Filters put into the report.
    Hope it helps.
    Thanks,
    Abhishek.

  • Lookup column in calculated column formula

    I have a Lookup column(Discountfirst) which has Number.
    I also have another Calculated column(Finaldate) with Resulttype DateTime.
    One more column(DateofReceipt) in Date.
    My Calculated column formula looks like this
    =(DateofReceipt)+(Discountfirst).
    I get an error
    "One or more column references are not allowed, because the columns are defined as a data type that is not supported in formulas".
    I googled and came to know I can't use Lookup Column in Calculated field.
    Any suggestion how can do this ?

    This can't be done using calculated columns because calculated columns can only be used for columns on the same list.
    Using SharePoint Designer Workflows you can just use Create List Item and Update List Item actions so that whenever a user adds a value the item will be added in another list's column which contains the previous amounts already.
    http://stackoverflow.com/questions/16295567/how-to-create-calculated-column-with-data-from-another-list
    https://social.msdn.microsoft.com/forums/sharepoint/en-US/01989169-eac7-4f28-809d-6e5af400fb03/lookup-column-to-calculated-field-showing-string-at-beginning
    Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

  • How to make the calculation or formula in bottom of the coloum

    How to make the calculation or formula in bottom of the coloum in Discoverer report.
    Regadrs
    Manikandan

    Hi Ros
    You have a couple of issues, one that is simple to resolve and one that is not so simple.
    First, the simple one - the word TOTAL. To alter the word that Discoverer inserts next to a total, or to even remove the word altogether, use this workflow:
    1. Right-click on the total and from the pop-up menu select Edit Total
    2. At the bottom right-hand corner of the Edit Total dialog box is the area where the label is maintained. You will see a checkbox for the label
    3. If you uncheck the label you can change the label to anything you like, including nothing
    4. After you have set the label, click OK and close the Edit Total dialog box
    Note: In Desktop, this is done via a drop-down from the Total dialog box. If you click the drop-down, the last item in the list is called Generate Label Automatically. If you uncheck this you can create your own label.
    Your second issue concerning the non-totaling of the grand total on some items means that there is something preventing one or more of the totals from calculating. First of all, try to determine which item or items is causing the problem by adding individual totals to each of the desired columns. You will eventually find the column which has the culprit. If you use the above workflow to suppress the display of any labels your total line will look as though you have totaled all items.
    Next, having found the column that will not total, try to figure out why the values will not add up. Could the column be a calculated item? If so, it is possible that you have used SUM on the outside of the calculation, like this:
    SUM(some item - some other item) - this will not total if the original items themselves are in the query and are also being summed. This is because you are mixing aggregate and detail items within the total.
    Try changing the formula like this:
    SUM(some item) - SUM(some other item) and see if this helps.
    If this is not the cause then try changing the formula for that column's total to CELL SUM instead of SUM. This causes Discoverer to literally add the values in the column.
    If this is not the cause, could you possibly be trying to total repeated values? By default, this is disabled in the later versions of Discoverer. The repeated values will be caused if you have multiple joins in your query and the item that you are totaling is from the many end of a one to many relationship. Suppose you had items from a header table and line table in the same worksheet with there being multiple lines for the same header, and now let's say you have a column which is returning something from the header. That value will get repeated and if you try to total it would generate the wrong answer, hence out of the box Discoverer is trying to protect you from yourself.
    However, it could be that the column really should be totaled but because Discoverer has detected a one to many join it will not total that column. To prove that this is the reason, change the join from a one to many to a one to one. Don't worry, this won't stop the query from working. If this allows the total to work then you can either leave the join as it is with a one to one, which won't harm Discoverer or you can edit the pref.txt on the server and change one of the preferences.
    The preference I would change is called AllowAggregationOverRepeatedValues. By default this is disabled and will be set to 0. Changing this to a 1 will now tell Discoverer that repeated values can now be totaled. Don't forget to apply the preferences correctly by execiting applypreferences.bat, on Windows or applypreferences.sh, in Linux or Unix, and then stopping and restarting the Discoverer server.
    I hope this helps
    Best wishes
    Michael Armstrong-Smith
    URL: http://learndiscoverer.com
    Blog: http://learndiscoverer.blogspot.com

  • Problem inText Variable cannot replace 0calmonth in calculated keyfigure

    Hi ALL,
    I am facing a problem while creating text variable for calculated keyfigure saying canot find the replacement for 0calmonth, I have 5 restricted keyfigures individually created a text variable for it. and now i have created  a calculated keyfigure for displaying text using same text variable .
    Could you please tell me what might be the problem.How to rectify .do response urgent plz.
    Thanks much.

    Hi,
    Please find below the code.
    WHEN 'ZMON_TEXT_CE'.   ---Text Variable
           DATA:text2(60),
                 c_calmonth(6),
                 l_month  TYPE /bi0/oicalmonth,
                  t_year(4),
                 zktx TYPE fcktx.
            CLEAR :text2,c_calmonth,t_year.
            LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = '0CALMYL'.  ------user input variable
              c_calmonth  = loc_var_range-low.
            ENDLOOP.
            l_month = c_calmonth+4(2).
            t_year = c_calmonth+0(4).
            SELECT ktx FROM t247 INTO zktx WHERE spras = 'EN' AND mnr = l_month.
            ENDSELECT.
            CONCATENATE zktx '-' t_year INTO text2.
            IF text2 <> ' '.
              l_t_range-sign = 'I'.
              l_t_range-opt = 'EQ'.
              l_t_range-low = text2.
              APPEND l_t_range TO e_t_range.
            ENDIF.
    Hope it helps.
    Regards,
    AL

  • Naming convention of calculated keyfigure

    Hi Experts,
    This is the first time we are creating any calculated keyfigure in our system and while creating we are getting authorization error. When we contacted our basis friends they told that its a naming convention issue. I want to know what would be the naming convention of a calculated key figure in our system. Can you please help me how to find this naming convention?
    Thanks in advance for your help.
    Regards,
    Brahma Reddy

    "You do not have authorization to add or create".
    This message purely indicates it is authorization issue. Work with your Basis guys to  get the required access.
    May be some of the roles are not assigned to your user id. or
    In which system you are making changes, if it is prodcution try not to make any changes and make changes in dev system and move to production system.
    Hope this helps.
    Regards,
    Reddy

  • Calculated Keyfigures Fromm Bex Analyzer into BO without Unit

    Hi Guys,
    We built a Universe on top of Inventory Query from Bex Query Designer. We have  lot of Calculated Key figures built on Restricted Keyfigures.
    In the Universe some Calculated Keyfigures are shown as folders with Unit value and some of them are not shown in folder and hence it is not bringing the Unit.
    If we run the same Query from Bex Analyzer all the Calculated Keyfigures have units associated with them.
    Can you please let me know if any of you have the same issue.
    Thank you,
    PVK

    Hello PVK,
    I recommend to post this query to the [Integration Kits - SAP|BusinessObjects Integration Kits; forum.
    This forum is dedicated to topics related to the BusinessObjects Integration Kit for SAP.
    It is monitored by qualified technicians and you will get a faster response there.
    Also, all SAP Kit queries remain in one place and thus can be easily searched in one place.
    Thanks a lot,
    Falk

Maybe you are looking for