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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
pvural
Advocate I
Advocate I

Quick Measure: Incorrect YOY calculation - handling negatives

Hello,

 

YOY quick measure in Power BI results incorrect calculation when previous year data is negative or vice versa. Following quick measure formula results a negative 217% YOY where previous year value is minus 463 and current year value is plus 541. 

 
YTD_Total Sales Gross YoY% =
VAR __PREV_YEAR =
    CALCULATE(
        SUM('Append1'[YTD_Total Sales Gross]),
        DATEADD('Date_Key'[Date], -1, YEAR)
    )
RETURN
    DIVIDE(SUM('Append1'[YTD_Total Sales Gross]) - __PREV_YEAR, __PREV_YEAR)
 
Is there a way to edit the quick measure to add ABS? I'd prefer not create seperate measures for each metric we are tracking and calculate the YOY for each. It will be a very tedious workaround.
 
Thanks,
Petek
1 ACCEPTED SOLUTION
stevedep
Memorable Member
Memorable Member

Hi,

Your formula would be:

YTD_Total Sales Gross YoY% =
VAR __PREV_YEAR =
    CALCULATE(
        SUM('Append1'[YTD_Total Sales Gross]),
        DATEADD('Date_Key'[Date], -1, YEAR)
    )
RETURN
    DIVIDE(SUM('Append1'[YTD_Total Sales Gross]) - __PREV_YEAR, ABS(__PREV_YEAR)

 

Notice the ABS wrapped around the Denominator in the Divide statement. 

 

Please mark as solution if this helps you. Kubos are much appreciated.

 

Kind regards, Steve. 

View solution in original post

4 REPLIES 4
stevedep
Memorable Member
Memorable Member

Hi,

Your formula would be:

YTD_Total Sales Gross YoY% =
VAR __PREV_YEAR =
    CALCULATE(
        SUM('Append1'[YTD_Total Sales Gross]),
        DATEADD('Date_Key'[Date], -1, YEAR)
    )
RETURN
    DIVIDE(SUM('Append1'[YTD_Total Sales Gross]) - __PREV_YEAR, ABS(__PREV_YEAR)

 

Notice the ABS wrapped around the Denominator in the Divide statement. 

 

Please mark as solution if this helps you. Kubos are much appreciated.

 

Kind regards, Steve. 

Thank you Steve - you are indeed "Resolver" 🙂

 

Cheers,

Petek

lbendlin
Super User
Super User

Why would you want to do an ABS conversion?  What is your definition of YoY performance when the previous year was -20 and this year is 30 ? IMHO you should BLANK() out results where the prior year was negative.  Unless both are negative, for example prior year -20 and this year -10 ?  Nah, still doesn't make sense.

Thank you for your response. I hear you, but in our world none of the YOY or growth numbers alone make sense unless we present them with context and a narrative. In this scenario, pre-built quick measure is giving a negative growth although it is positive.  

 
 
 
   w/ABSw/out ABS
CurrentPreviousIncrease (Decrease)% Growth (YOY)% Growth (YOY)
     
1055100%100%
510-5-50%-50%
10-515300%-300%
-105-15-300%-300%
-5-10550%-50%
-10-5-5-100%100%

 

In the spirit of providing solutions, how do you suggest the quick measure to be edited so it returns BLANK(). Your response might help others whose scenario fits the definition.

 

Thank you,

Petek

 

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.