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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
31415926
New Member

Year to Year only show specific values

Hi,

 

I wanted to present the sales of 2021 and 2022 with YOY change %.

YOY = DIVIDE(([Total Sales This Year]-[Total Sales Last Year]),[Total Sales Last Year])

As you can see below, the YOY value is -100% since March because "total sales this year" is 0.

 

YOY.png

I wanted to only present the months that have an actual value in YOY % (in this case, Jan and Feb).

So I used a new measure: 

YOY % = CALCULATE([YOY],FILTER('2021&2022',[YOY]<>-1))
The new measure showed indeed only the first 2 months, however, with different and wrong values (174% en 1678%). I don't even know how these values come from.
 
Could you please help me check what went wrong? Or is there a better way to filter the values of YOY only?
Many thanks!

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

YOY % =
var currentSales = [Total Sales This Year]
var prevSales = [Total Sales Last Year]
return IF( currentSales > 0, DIVIDE( currentSales - prevSales, prevSales ) )

will only return a value if there are sales for this year, otherwise it will return blank

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

YOY % =
var currentSales = [Total Sales This Year]
var prevSales = [Total Sales Last Year]
return IF( currentSales > 0, DIVIDE( currentSales - prevSales, prevSales ) )

will only return a value if there are sales for this year, otherwise it will return blank

Thanks a lot for your help!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.