Expand my Community achievements bar.

Join us January 15th for an AMA with Champion Achaia Walton, who will be talking about her article on Event-Based Reporting and Measuring Content Groups!

Percentage Difference

Avatar

Level 1

I am trying to calculate the percent difference between two numbers whether it is greater than the original number or less than the original number.      My Original Number is "A1" and by new number is "A2".   The formula I am using is :

 

event.value = Math.abs(Number(this.getField("A1").valueAsString) / Number(this.getField("A2").valueAsString));

 

This works correctly if A2 is greater than A1 but if it is less than A2 it does not 

 

1. A1= 16,000 A2=17,456 Outcome is 91.66%

2. A1= 16,000 A2=14,500 Outcome is 110.34% (Should be 90.625%)

 

Any help with be greatly appreciated, thank you.

4 Replies

Avatar

Community Advisor and Adobe Champion

Hi, 

 

Have you tried just adding an IF statement using Greater Than logic to change the order of the division?

 

I just did a simple example using static values, but:

Jennifer_Dungan_0-1718854148768.png

 

 

And to do this, I used:

Jennifer_Dungan_1-1718854241171.png

 

Basically, I check if A1 is greater than A2, if it is, then I divide A1/A2, otherwise I divide A2/A1

 

You can replicate this logic using your actual metrics that will change values rather than my sample using static values.

Avatar

Level 1

I really apricate your response. I don't know how to do what your asking.   

I am very new to calculations in adobe so if there is something very basic I can

follow I can apply it and hopefully learn from it. 

Avatar

Community Advisor and Adobe Champion

So what I showed above was the Adobe Workspace and the Calculated Metric Builder.

 

So I am assuming you have a table with two columns, one for A1 and one for A2?

 

You can select the two metric headers, right click, and choose "Create Metric from Selected > Divide" as a good starting point.

Jennifer_Dungan_0-1718891702225.png

 

 

This will create a simple A1/A2 column:

Jennifer_Dungan_1-1718891740884.png

 

 

But you can edit this, by hovering over the new metric, clicking on the (i) icon, then clicking on the pencil (if you don't see the pencil then your admin hasn't given you the rights to create calculated metrics, but if you have already been trying things, then you should have that)

 

You can use the "Add" button in the definition area to add functions:

Jennifer_Dungan_2-1718891911362.png

 

 

You will need to add an "IF" function, and inside the logical test, you will need to add a "Greater Than" or "Greater Than and Equal To" function... then just move around / add your metrics inside the formulas as in my screenshot, but using the actual metrics instead of my static content placeholders....

 

Jennifer_Dungan_3-1718892090548.png

 

Avatar

Level 1

I have it in an adobe PDF file.  

StevenZo_0-1718919259365.png

The formula is in the Properties section.  

StevenZo_1-1718919308260.png