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
lcasey
Post Prodigy
Post Prodigy

Calculated 2 years previous

Hello,

 

Does anyone know how I would write a correct formula?

 

Year 2 = CALCULATE([YTD Budget],ALLSELECTED('Calendar'[Year]) -2,ALL('Calendar'[Month]))

 

In the above formula I want to be able to select any year in the calendar table and have the formula go back 2 years in time and grab that entire years budget.

 

Adding the -2  breaks th eformula but you can see what I was trying to do. What should I be using?

 

01.jpg

4 REPLIES 4
Sean
Community Champion
Community Champion

@lcasey

 

YTD From 2 Ago =
CALCULATE ( [YTD Budget], DATEADD ( 'Calendar'[Date], - 2, YEAR ) )

If [YTD Budget] uses TOTALYTD - then the above will give you the YTD Total but from 2 years ago! Smiley Happy

Thanks,

 

My YTD budget is useing:

 

YTD Budget = IF(SUM('00-GLSummary'[Revenue]) > 0,  Abs(SUM('00-Budget'[BUDGETAMT])),sum('00-Budget'[BUDGETAMT]))

 

So this formula is blank for now. I am going to try and convert my YTD Budget to use TotalYTD

 

That sounds like a more sdtandard way to calculate amounts anyway.

Weird,

 

I changed my formula to:

 

IF(SUM('00-GLSummary'[Revenue]) > 0,  TOTALYTD(Sum('00-Budget'[BUDGETAMT]),'Calendar'[Date]),sum('00-Budget'[BUDGETAMT]))

 

and the YTD From 2 Ago = CALCULATE ( [YTD Budget], DATEADD ( 'Calendar'[Date], - 2, YEAR ) )

 

is still blank.

Hi @lcasey

 

Just to confirm that you do not have any filters in the Visual, Page or Report levels?

 

What I would suggest to troubleshoot, is to create a table and put the indivudual measures into the table with your dates. In doing so this can help visually see where the possible error is occuring.

 

I have done that in the past, which has helped me identify where I was going wrong.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

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.