cancel
Showing results for 
Search instead for 
Did you mean: 

Need Help in MACRO

Former Member
0 Kudos

HI All,

I am writing a MACRO for a requirement as below.

There are 3 keyfigures.

Keyfigure 1

keyfigure 2

Keyfigure 3

Keyfigure 1 = ( keyfigure 2 - keyfigure 3 / keyfigure 2 ) * 100

The above MACRO is working fine when Key

Accepted Solutions (1)

Accepted Solutions (1)

former_member209769
Active Contributor
0 Kudos

Hi Sameer,

Could you pls complete your qns?

Thanks - Pawan

Former Member
0 Kudos

ohh.. i am sorry.

My qs.

The MACRO is working fine if the KF2 is greater than KF3.If KF3 is greater than KF2 then it is giving wrong value.

Ex :- Case 1 - when KF2 is greater than KF3

                      KF2 = 100 and KF3 = 50. Then the calculation as below.

                     ( 100 - 50 / 100 ) * 100 = 50 (this is correct)

        Case 2 - When KF3 is greater than KF2

                     KF2 = 50 and KF3 = 100. The calculation as below.

                     ( 50 - 100 / 100) * 100 = -100(This is wrong it should be -50).

Sameer

Former Member
0 Kudos

Hi Sameer

Does these key figures allow decimal values? You can check this by right clicking on the Planning Area -> Change -> Key Figures -> Select the key figure and click on Details -> Column "Decimal Places".

Thanks,

Prasun

former_member209769
Active Contributor
0 Kudos

Hi Sameer,

I am not sure if you gave the wrong data to explain, or I am misunderstanding.

your calculation is KF1 = (KF2- KF3)/KF2 *100

For the second case where KF2 = 50, KF3 = 100,

the calculation would be

KF 1 = (-50)/50*100 = -100.

What is the issue in this?

Thanks - Pawan

Former Member
0 Kudos

Hi Sameer,

I would suggest to use proper brackets in each step. By arithmetic rule, division would take place first, then the subtraction (in bracket) and then the multiplication.

The results for KF1= ((KF2-KF3)/KF2)*100 & KF1= (KF2-KF3/KF2)*100 would be different.

Regards

Manotosh

former_member187488
Active Contributor
0 Kudos

Hi, I suppose your calculation should be :

Keyfigure 1 = ( keyfigure 2 - keyfigure 3 ) / keyfigure 2 * 100.

How did you define the macro? Is it possible for you the attach it?

Former Member
0 Kudos

Hi Pawan,

Thanks for your reply

You are correct.. i realized it after posting this.

Marked u r reply as correct..i wonder how to assign points.

Thanks

Sameer.

Answers (0)