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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Previous interval date not working

Hi,

 

I am trying to create a measure that returns the previous year's value, using the following expression: 

 

Previous Year Value = CALCULATE([Total Value],
DATEADD('Table'[Year],-1,YEAR
)
)
 
However, when I visualise this in a table, the measure does not work as intended - it only gives the aggregated total, but not the year by year (e.g. 2011 should be blank, 2012 should be 364341500 (2011's value) etc.).
 
timzedel_0-1673266772469.png

 

Can someone please explain what is wrong with my DAX? Power BI is not picking up any errosrs.
 
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi Mike,

 

The YEAR column in 'Table' has years 2011 - 2022 formatted as date.

 

Sample data here:

 

timzedel_0-1673267928413.png

 

 

I've just created a DimDate table using a simple 

DimDate = SUMMARIZE('Sheet1 (2)','Sheet1 (2)'[Year])

and have used the Year column in DimDate in the DATEADD expression, this seems to have solved the problem.

 

However, I am confused as to why using the Year column in DimDate as opposed to Year column in the original Table made a difference - they were both formatted as date so what was the issue? 

 
 

View solution in original post

3 REPLIES 3
Mikelytics
Resident Rockstar
Resident Rockstar

Hi @Anonymous.

 

For using Time Intelligence functions like DATEADD you need columns with dates. I assume you do not have that right? Can please show the dataset below with sample data?

 

Best regards

Michael

 

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!
Anonymous
Not applicable

Hi Mike,

 

The YEAR column in 'Table' has years 2011 - 2022 formatted as date.

 

Sample data here:

 

timzedel_0-1673267928413.png

 

 

I've just created a DimDate table using a simple 

DimDate = SUMMARIZE('Sheet1 (2)','Sheet1 (2)'[Year])

and have used the Year column in DimDate in the DATEADD expression, this seems to have solved the problem.

 

However, I am confused as to why using the Year column in DimDate as opposed to Year column in the original Table made a difference - they were both formatted as date so what was the issue? 

 
 

@Anonymous , if you have date table then only then this will work (also you need have date table and use year from date table) 

Previous Year Value = CALCULATE([Total Value],
DATEADD('Date'[Date],-1,Day
)
)

 

Using a separate date/year table

 

//Only year vs Year, not a level below

This Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

 

Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

 

 

 

 

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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Solution Authors