"If" in Formula in Bex

Hi ,
I want to create a Formula in which I want to assign a value to a KF if a condition is satisfied... Any advise on how to write "If" statement in Formula in Bex
ex:
if char1 = "xyz" then KF = 0
Any help...

hi tanu,
First of all we cant bring char into formula for that you need to use formula varaible with replacement path..to make char as a KF
http://www.sd-solutions.com/SAP-HCM-BW-Replacement-Path-Variables.html
one that brough into as KF then you can write simple If like below
(( KF == 'xyz' ) * 0 + KF ) 

Similar Messages

  • Redefining formulas for BEX queries.

    Hello all,
    Going a little bit further, I realise now that it would be better to have some complex calculations stored in some formulas to be reusable in many queries.
    So, I think I can create and define new formulas by using BAdis. I have read something like this in SAP HELP. I'm doing this by creating a new implementation that redefines the interface method IF_EX_RSAR_CONNECTOR~GET.
    I have never done this before, so I would appreciate any help on this. Now I could create this redefinition of that interface method but, how can I "insert" the new formula in BEX to make it available. I think I should create the formula definition before but I don't know where, the only thing I know is that the formula should begin with "C_".
    Am I in the right path?

    Hello Roberto and everybody,
    this is what SAP Help says about this:
    BAdI: Customer-defined Functions in Formula Builder
    Use
    This Business Add-In (BAdI) is used in the formula builder transformation library. You use this BAdI to integrate user-defined functions into the transformation library of the formula builder. In this way, you can make special functions that are not contained in the transformation library available for regular use.
    Requirements
    <u>The technical name of a user-defined function
    Must be specified
    Must be unique
    Must begin with 'C_'
    Can contain only alphanumeric characters ( ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_) (lower-case letters, empty spaces and special characters are not allowed)
    Can be a maximum of 61 characters long.</u>
    Standard settings
    The BAdI can be used repeatedly. Is it not filter-dependent.
    Activities
    After you have called up the IMG activity, a dialog box appears in which you enter a name for implementation.
    If implementations have already been created for this BAdI, a dialog box appears in which the existing implementations are displayed. In this dialog box, choose Create and proceed as follows:
    1. In the Implementation field, enter a name for the implementation of the BAdIs and choose Create.
    2. The initial screen for creating BAdI implementations appears.
    3. In the initial screen, in the Short Text for Implementation field, enter a short text for the implementation.
    4. Choose  the Interface tab index.
    5. On the tab page, the field Name of Implemented Class is filled automatically, since the system assigns a class name based on the name of your implementation.
    6. Save your entries and assign the implementation to a development class.
    7. Position the cursor on the method and double-click on it to reach the method editing screen.
    8. Between the statements method <Interface Name>~<Name of Method>. and endmethod. the coding for your implementation.
    9. Save and activate your coding and return to the Change Implementation screen.
    10. Save your entries on the Change Implementation screen.
    Note: You can create an implementation for a BAdI and activate it later. If this is the case, close the editing screen now.
    11. Choose Activate.
    When you execute the application program, the coding you defined in the method is run through.
    See also:
    Method
    GET
    And what I can't find where to do is <u>underlined</u>.
    Don't know where to create the functions, because the BAdI is clear and also the method I have to redefine in my own Z_Implementation.

  • Formula in Bex - Syntax Error

    Hello,
    I'm doing a formula in BEx and i have to user IF, Then, Else but i don't know how.
    My formula should be like:
    if key_figure1 > 0
    then key_figure2
    else key_figure3
    i've made the following formula :
    ( key_figure1> 0 ) * key_figure2 + key_figure3
    but it doens't work, it makes the calculation and don't make the if condition.
    Help needed, thanks
    Maria

    Hello,
    you have to adopt the formula as below
    ( key_figure1> 0 ) * key_figure2 +  (key_figure1<= 0 ) *key_figure3
    Happy Tony

  • Excel formulas and BEx Hierarchies

    Is there a way to use Excel (2007) formulas against BEx (3.5) results that have a hierarchy so that when you expand or collapse a node the formula updates with it? I tried a structured reference but I get an error when expanding node and have to refresh the query.
    Thanx much!
    Al

    I wasn't aware about the differences in the IRR function between Numbers and Excel.  The subset of functions in Numbers 3 should be almost identical to their Excel equivalents. Are you sure?
    From Numbers help:
    IRR(flows-range, estimate)
    flows-range: A collection that contains the cash flow values. flows-range must contain number values. Income (a cash inflow) is specified as a positive number, and an expenditure (a cash outflow) is specified as a negative number.
    From Excel Microsoft support:
    Returns the internal rate of return for a series of cash flows represented by the numbers in values. These cash flows do not have to be even, as they would be for an annuity. However, the cash flows must occur at regular intervals, such as monthly or annually. The internal rate of return is the interest rate received for an investment consisting of payments (negative values) and income (positive values) that occur at regular periods.
    I'm pretty sure the sign convention is identical, as these two descriptions suggest.
    In any case, if you need XIRR and/or you work with large datasets with lots of columns, then you need Excel.
    SG

  • BW ERROR while calculating local formula in Bex analyzer

    Hi gurus,
    Their is an error comming up on a report which is  opened in Bex Analyzer. When we create local formula i encounter this error.
    It says"
    "Program error in class SAPMYSS1S method :uncaught exception "
    "System error in program SAPLRRK0 and form DELETE_FST-01"
    Not sure of why this error is comming up.
    DO we need to update a OSS note for this.
    Please suggest .
    Regards,
    Balaji Raj

    Search SCN & Marketplace.

  • Formula in BEX

    Hello,
    In our cube MM, the order value is repeated at each line, so that in the result in the query is wrong : for example 200 insteaed of 100
    Order        Item   Fiscal period    Order value   delivery value     invoice value
    5100000   1        200601             100              100                  0
    5100000   1        200604             100              0                     100
    I would like to create in BEX a formula that enables me to take into account in the result only the 1st occurence of the order value and that for each purchasing order.
    Can you help me ?
    Franck

    You can try the Key Figure properties -> Calculations -> Calculate single value as -> Maximum/Minimum. This might give you what you are looking for. But, make sure all the rows you need to combine has the same order value, else you might get incorrect results.
    Regards,
    Sree

  • What is the use of 'Convert to Formula' in BEx Report?

    Helo BI Gurus,
    After refreshing the query in BI, when I right click on the query report, I am getting an option 'Convert to Formula'. Can you please tell me the use of this option, and how we can use this in our report and what the result we will be getting?

    Hi Mathew,
        The Convert to Formula in Excel Allows you to Convert you Embedded Bex Query into API Calls. This enables you to Better Format the Excel Output by allowing you to move your Cells Around.
    This helps because when you refresh you Query all the Changes you make will be maintained.
    [More Info on Working with Formula|http://help.sap.com/saphelp_nw70/helpdata/EN/d3/015369f54f4a0ca19b28c1b45acf00/content.htm]
    Hope this Helps
    Datta.

  • FORMULA IN BEX ANALYSER - NEED HELP

    Hi all - here is my deal ....
    I have in a cube information for Articles and replacement Articles
    EX :
    CUBE
    *Material -  Price  - Replaced Material *
    A1        3.00
    A2        3.10          A1
    In Bex I would like to make a query to have this kind of result
    REPORT
    Material  -  replaced material    -  Material Price  -  Price of material replaced 
    A1                         /                       3.00                         /
    A2                       A1                      3.10                       3.00
    My problem is to find the right formula to get on the second line of the report the price of Material A1
    Both line should be reported on my report
    How could I get on the second line the price of Material of the first line.
    Thanks for your help
    Alain

    Hi all - here is my deal ....
    I have in a cube information for material and material replace by.
    EX :
    CUBE
    *Material /  Price  / Replaced Material *
    A1  /      3.00
    A2   /     3.10    /      A1
    In Bex I would like to make a query to have this kind of result
    REPORT
    Material  /  replaced material   /  Material Price  /  Price of material replaced 
    A1           /              #                 /     3.00           /           *
    A2           /            A1                /      3.10         /              3.00
    My problem is to find the right formula to get on the second line of the report the price of Material A1
    Both line should be reported on my report
    How could I get on the second line the price of Material of the first line.
    Thanks for your help
    Alain

  • Formula in BEx Query Designer

    Hi Friends,
    I have a requirement to create a formula, that checks the following condition.
    1) if Keyfigure A is 0 and Keyfigure B is 0 then the Value of this Formula should be null(blank space).
    2) if Keyfigure A is 0 and Keyfigure B is NOT 0 then the Value of this Formula should be 0.00
    i have written the following
    1) I dont know how to display blank space...
    2) (A == 0) AND (B == 0)*0
    Can you please tell me how to achieve this (1) and if the (2) formula is right.
    Thanks in Advance.
    Regards,
    Vinaya Paulraj.

    what product you use, "crystal Report" or wat
    if crystal reprot
    then you can use this formula
    if a=0 and b=0 then null
    else 0
    and you can fix the format of the formula to 0.00
    hope this helps you
    good luck

  • Use of Aggregation tab in New formula in BEx quert designer

    Hi,
    I used the aggreagtion tab in setting up new formula for key figures. i selected the maximum and given particular charasterstic field and saved.
    when i looked in the output i cant see any difference.
    we are setting formula for key figures and its asking for charasterisic field i coulnt get clear idea about this.
    can any one tell me what is the use of this aggregation tab?
    In formula screen for the general tab  what ever the calculation i am doing there its working properly, only in the aggreation tab whatever i am setting only that is not working.
    Regards,
    Thanesh

    Hi Thanesh,
    Refernce characteristic field should be selected in relation to which the key figure is to be aggregated with the exception aggregation. Often this is a time characteristic. However, you can use any characteristic.
    Best Example
    If you want to count sales orders
    By giving COUNT of all values with refence charactersitc as Sales document, you will get the desired result.
    There are three aggregation options:
    ●      Minimum (MIN): The minimum value of all values displayed in this column is displayed in the results row.
    ●      Maximum (MAX): The maximum value of all values displayed in this column is displayed in the results row.
    ●      Summation (SUM): The sum of all values displayed in this column is displayed in the results row.
    Another Example :The key figure Number of Employees would, for example, be totaled using the characteristic Cost Center, and not a time characteristic. Here you would determine a time characteristic as an exception characteristic with, for example, the aggregation Last Value.
    Hope this helps
    Regards,
    Aparna

  • %CT and %GT formula in  BEx report (query) ??

    Hi all,
    I need to create one formula which shows the <b>Net Sale value(One KF) of Total Net sale value(from column-total overall result for net sale)</b> . Can someone help? Thanks
    J.

    Hi all,
    Now it is working but the result is not what I expected. <b>For example,</b> <b>this report period is to display Net sales value from 01/2006-03/2006(monthly) by customers.</b> There is one column-<b>'overall result'</b> next to the <b>column-Net sales value(period 03/2006)</b>. I <u>only need one more column which will show % of total Net sales value for each custome.</u> But I have % of total net sales value in each month for each customer. Can someone tell me how to resolve it? Thanks.
    J.

  • How to use rounded values in BEx Formulas

    Hello,
    I have the following question. Is it possible to use rounded values up to a certain # of decimal points in BEx Formulas?
    I have the following problem.
    Consider this:
    keyfigure val 1 = 0.416666667
    keyfigure val 2 = 72
    val 3 (BEx Formula)  = val 2 / val 1 = 172.799999862
    However, what I need to do is this.
    val 1 & val 3 should rounded up to 2 decimal points. So, I really need the report to show this:
    val1 = 0.42
    val2 - 72
    val 3 = val 2 /val 1 = 171.43
    I changed the number of decimal places on val 1 and val3 to be 0.00. However, it appears that these rounded values are not taken into account in  the Formulas, as if the OLAP still uses the original values from the backend with 9 decimal points. So, no matter how many decimal points I use on the Display tab for a key figure, my val3 or result of my formula is always taking into account the 9 digit decimal values, not rounded values that I want. So in the example above, my val 3 comes to 172.80, which it should be 171.43 instead of you use the rounded values in the calculation.
    Please let me know if there is any workaround where I could force my BEx Formula to utilize the rounded values and not actual values from the backend DSO. Or any other solution.
    Thank you

    If you create a Formula in BEx Query Designer like the one below, it works:
    val3 = val2 / ( TRUNC ( ( val1 * 100 + 0.5 ) ) / 100 )
    The TRUNC function (among other things) actually ensures that your formula takes into account the rounded values that you want.

  • BEX formula

    Hi all,
       I have a problem while defining a formula in BEX Query.
    My formula looks like this.
    (1- ( abs(X - Y) / X )) < 0) * 0 + not(1-( abs( X - Y) / X ))<0)*10
    Requirement is that if X = 0 then output = 0 else 10.
    In th above formula used, if X = 0, it gives error ' divide by zero'.
    I tried to use NONDIV0( )  for the division part, if X = 0, output = 10, which is an error again.
    This is jst a sample of a complex formula I am using. I dnt want to change the whole structure of the formula.
    Any suggetions will be rewarded.
    Regards,
    Adarsh

    Hi,
    (1- ( abs(X - Y) / X )) < 0) * 0 + not(1-( abs( X - Y) / X ))<0)*10
    Requirement is that if X = 0 then output = 0 else 10.
    Your requirement just mentions X, why do you have Y in your formula? For the above requirement, you can simple write
    (X <> 0) * 10

  • BEX query formula

    HI,
        We want to write below formula in bex query, Kindly guide me, for inital(no value) i dont know what i have to use in query formula.
    if(temp = inital)
    elseif(temp>0)
    Thanks

    We can't check for SPACE, NULL, INITIAL in bex.... And the IF statement you can include keyfigure only.
    If you want to check for characteristics, then you have to go for Virtual characteristics.
    Search in the forum, you will get lot of thread on Virtual Characteristics.
    --- Thanks...

  • Debug Bex Formula

    Dear Experts,
    I have written a formula in Bex using boolean operators.  Now how can i possibly debug this formula?
    Please help.
    Tony

    I have a kf called 'net amt after adjust'. I have another formula which counts the 'no. of orders'. Now i want to specify an if condition in a formula that says if 'net amt after adjust' is zero then vaue is zero else if 'net amt after adjust' not zero then result is equal to 'no. of orders'.
    What i did was
    ('net amt after adjust' == 0) * 0 + ('net amt after adjust' <> 0) * 'no. of orders'
    But the 'net amt after adjust' does not seem to equate to zero but the result is always 'no. of orders'. I tried to take the decimal places into consideration but it didnt help.
    Please help.
    Tony

Maybe you are looking for