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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

% change not working if previous year value is 0

I have the following measure that calculates % change 

 

% Vic Change =
VAR _Num =

CALCULATE (
IF (ISBLANK(DISTINCTCOUNT('Table'[ID])), 0, (DISTINCTCOUNT('Table'[ID]))),
FILTER(ALL('Date'[FY]),
'Date'[FY] = MAX('Date'[FY])))
VAR _Den =
CALCULATE (
IF (ISBLANK(DISTINCTCOUNT('Table'[ID])), 0, (DISTINCTCOUNT('Table'[ID]))),
FILTER(ALL('Date'[FY]),
'Date'[FY] = MAX('Date'[FY])-1))
 
VAR _PercentChange = IFERROR((_Num-_Den)/_Den ,0)
RETURN
_PercentChange

It works perfectly 99% of the time, however if the previous year that is being compared to (defined in variable "_Den") has a value of 0, then no matter what the current year is (variable "_Num"), the % change shows a value 0f 0%. For example, the following should say an increase of 200%, not 0%:

LloydThomas_0-1647332301805.png


As mentioned works fine other than this, and even works fine for if both values are 0, as expected 0% change is shown:

LloydThomas_1-1647332341532.png

 

It also works fine if the current year value is 0 and previous year is greater than 0.
Any help appreciated.

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Try like

 

measure =
_Num = CALCULATE ( (DISTINCTCOUNT('Table'[ID])),
FILTER(ALL('Date'[FY]),
'Date'[FY] = MAX('Date'[FY])))
VAR _Den =
CALCULATE (
DISTINCTCOUNT('Table'[ID]),
FILTER(ALL('Date'[FY]),
'Date'[FY] = MAX('Date'[FY])-1))

VAR _PercentChange = divide(_Num-_Den),_Den ,0)
RETURN
_PercentChange

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak , this measure just returns a blank % change. (I had to add another open bracket after the divide fucntion to get the measure to work, but yes still returns blank value)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors