Skip to Content
avatar image
Former Member

query calculation

Hi Gurus,

how can i implement the logic below in a global definition of a query

IF 'A' > B' THEN 0

OTHERWISE as below

"( 1 - A' / B' ) * 100"

Highlighted in double quots is the current calc for the key figure..

Ur reply will be appreciated. Thank u

Dave

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    May 14, 2006 at 11:50 PM

    Hi Dave:

    Create a New Calculated Key Figure. In the formula, write this Code:

    (A>B)(0) + (NOT(A>B))((1-(A/B))*100))

    Let me know if you find any issues.

    Good day

    Ram Chamarthy

    Message was edited by: Ram Chamarthy

    Message was edited by: Ram Chamarthy

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi ram,

      thanks for ur reply, but dont we need to put any IF or OTHERWISE statements in the code..Will ur code work without this. I dont understand this logic in BEX as iam new to BEX. Please explain me in detail. Thank u

      Dave

  • avatar image
    Former Member
    May 15, 2006 at 11:28 AM

    Hi,

    You can also write as:

    (A>B)0 + (A<=B)((1-A/B)*100)

    shylaja.

    Add comment
    10|10000 characters needed characters exceeded

  • May 15, 2006 at 12:05 AM

    Hi Dave,

    Nothing further is needed.

    BEx logic is a little different from ABAP:

    If you read carefully, u will get the logic.

    I will explain further in a minute:

    RESULT = Part-1 + Part-2

    Case A>B:

    Part-1

    (A>B)*(0)

    A>B, so the condition = 1 . Result of first part = 1*0 = 0.

    Part-2

    (NOT(A>B))((1-(A/B))100))

    Here, the condition = 0 because of NOT. So, the result = 0

    RESULT = 0 + 0.

    Case A<B or A=B:

    Part-1

    (A>B)*(0)

    the condition = 0 . Result of first part = 0*0 = 0.

    Part-2

    (NOT(A>B))((1-(A/B))100))

    Here, the condition = 1 because of NOT.

    So, the result is what you want

    RESULT = 0 + Part-2.

    Yes, its pretty neat.

    Ram Chamarthy

    Message was edited by: Ram Chamarthy

    Add comment
    10|10000 characters needed characters exceeded

  • May 15, 2006 at 12:19 AM

    Hi Dave:

    I already finished. Ask me any particular part if you want to.

    Write the Code & let me know.

    Good day

    Ram Chamarthy

    Message was edited by: Ram Chamarthy

    Add comment
    10|10000 characters needed characters exceeded

  • May 15, 2006 at 11:14 AM

    Hi Dave:

    I don't worry about points.

    If I am missing a bracket, your BEX Query Designer will correct it. Its pretty good with syntax (unlike ABAP).

    When you completed the Code in BEx, let me know.

    Good luck

    Ram Chamarthy.

    Add comment
    10|10000 characters needed characters exceeded