Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MHongisto
Frequent Visitor

Quick measure - Percentage difference

If I want to calculate percentage of costs vs sales amounts, I tried using the quick measure percentage difference. It gave me this code:

 

Measure1 % difference from Sales amount =
VAR __BASELINE_VALUE =
SUM('Sales'[Sales amount])
VAR __VALUE_TO_COMPARE =
'Sales'[Measure1]
RETURN
DIVIDE(__VALUE_TO_COMPARE - __BASELINE_VALUE; __BASELINE_VALUE)

 

This gives a negative percentage. If I remove the substraction in the DIVIDE line to:

 

DIVIDE(__VALUE_TO_COMPARE; __BASELINE_VALUE)

 

The return is the correct percentage that I would get with:

 

Measure% = CALCULATE('Sales'[Measure1]) / SUM('Sales'[Sales amount]) *100

 

Is this an issue with me not understanding what "Percentage difference" is meant to do or is this something else?

 

1 ACCEPTED SOLUTION
v-jiascu-msft
Employee
Employee

Hi @MHongisto,

 

"Percentage difference" is under the submenu "Mathematical operations". It looks like a math theory, which evaluates the difference and compare with the base value. Please refer to Percent of Increase or Decrease if you'd like to.

 

Best Regards!

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-jiascu-msft
Employee
Employee

Hi @MHongisto,

 

"Percentage difference" is under the submenu "Mathematical operations". It looks like a math theory, which evaluates the difference and compare with the base value. Please refer to Percent of Increase or Decrease if you'd like to.

 

Best Regards!

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

There's an issue when the base value is negative and the compared value is positive. In general, if the numerator indicates the direction, i.e. increase or decrease, then the denominator must have the absolute value. I am getting around the error in quick measure formula by adding ABS(__BASELINE_VALUE). 

--Thus changing

RETURN
DIVIDE(__VALUE_TO_COMPARE - __BASELINE_VALUE; __BASELINE_VALUE)

--to

RETURN
DIVIDE(__VALUE_TO_COMPARE - __BASELINE_VALUE; ABS(__BASELINE_VALUE))

Thank you! So it was an issue with me not understanding math or English.

cs_skit
Resolver IV
Resolver IV

Percentage type just displays 0.7 or 1.5 as 70 % or 150%

 

So DIVIDE(Sales;Base) is correct if your sales are 1500 and your base is 1000 result is 1.5 so displayed as 150% when you change it to Percentage

The Quick measure - Percentage difference calculation automatically puts the subtraction in DIVIDE. I don't understand why. Bug or feature?

Its a Percentage DIFFERENCE

Its just a recommendation.

It makes sense in many scenarios like:

 

Base 1000 Value 1020

Quick measure gives you 2%

 

Does not mean that its always correct in your specific scenario if you don't want 2% but 102% then you don't subtract.

Theres no right and wrong here depends on what you need.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.