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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.