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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Year-to-Year formula

Hello everybody,

 

I have a slight problem for my Year-to-Year formula. I want to calculate the evolution of sales from 2020 to 2021.

 

It goes as follows:

Conso Net Sales = SUM('DATA (2)'[CONSO NET SALES1])

 

- ConsoNetSales PY (Previous Year) = CALCULATE([Conso Net Sales],CALCULATETABLE(FILTER('DATA (2)','DATA (2)'[CONSO NET SALES1]),DATEADD('Calendar'[Date], -1,YEAR)))
 
- ConsoNetSales YOY (Year-to-Year) =
VAR ValueCurrentPeriod = [Conso Net Sales]
VAR ValuePreviousPeriod = [ConsoNetSales PY]
VAR Result =
IF(NOT ISBLANK(ValueCurrentPeriod) && NOT ISBLANK(ValuePreviousPeriod), ValueCurrentPeriod - ValuePreviousPeriod)
RETURN
Result

 

So everything works. The only problem is that for some of my clients, I don't have data for 2020 and therefore, it does not want to show up in my Waterfall graph.

I know also the solution: I just have to indicate PowerBI that if there is no Data for 2020 (Previous Year), it just has to substract the data of 2021 with 0.

 

But I don't know how to add that in YOY formula...

 

Can you please help me?

 

Thank you very much

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , based on what I got

 

ConsoNetSales YOY (Year-to-Year) =
VAR ValueCurrentPeriod = [Conso Net Sales]
VAR ValuePreviousPeriod = [ConsoNetSales PY]+0
VAR Result =
ValueCurrentPeriod - ValuePreviousPeriod
RETURN
Result

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

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , based on what I got

 

ConsoNetSales YOY (Year-to-Year) =
VAR ValueCurrentPeriod = [Conso Net Sales]
VAR ValuePreviousPeriod = [ConsoNetSales PY]+0
VAR Result =
ValueCurrentPeriod - ValuePreviousPeriod
RETURN
Result

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

Easy but efficient solution! Thank you very much

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.