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

10|10000 characters needed characters exceeded

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

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

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

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

10|10000 characters needed characters exceeded
• Former Member

Thanks Ram,

will wait for ur explanations.

Dave

• 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

10|10000 characters needed characters exceeded
• Former Member Former Member

Hi Ram,

I couldn't assign points..the screen isn't showing up..

Dave

• May 15, 2006 at 11:14 AM

Hi Dave: