cancel
Showing results for 
Search instead for 
Did you mean: 

query calculation

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

udayabhanupattabhiram_cha
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

You can also write as:

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

shylaja.

udayabhanupattabhiram_cha
Active Contributor
0 Kudos

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.

udayabhanupattabhiram_cha
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Ram,

I think u missed a opening brace in the 2nd part.. Please correct me if i am wrong. Thnk u

Dave

former_member188325
Active Contributor
0 Kudos

Hi Dave,

where is opening balance here?Above formula is perfect one...i think you missed out to mention opening balance.

thnaks

Former Member
0 Kudos

Hi Ram,

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

Dave

udayabhanupattabhiram_cha
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Thanks Ram,

will wait for ur explanations.

Dave