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

Calculating difference/change from the previous date or version.

Hi, 

 

I'm struggling finding the difference of value between dates. They are irregular and aren't monthly or yearly. 

 

My desired outcome would be a measure that calculates difference and change of the value.

 

something that looks like difference column

 

thanks

Coderegiontest datescoredifference
AUS05/07/19900
AUS09/08/1913040
ACA10/07/19500
BUS05/07/19800
BUS09/08/1970-10
BCA10/07/19750
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try as new columns

last date = maxx(filter(Table, Table[Code] = earlier(Table[Code])&& Table[region] = earlier(Table[region]) && Table[Date] < earlier(Table[Date])),Table[Date])

difference = Table[score] - maxx(filter(Table,  Table[Code] = earlier(Table[Code])&& Table[region] = earlier(Table[region])  && Table[Date] = earlier(Table[last date])),Table[score])

 

As new measures

Last Day Non Continous = CALCULATE(sum('Table'[score]),filter(all('Date'),'Date'[Date] =MAXX(FILTER(all('Date'),'Date'[Date]<max('Date'[Date])),'Table'['DAte'])))

Change = sum('Table'[score])- [Last Day Non Continous]

 

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 , Try as new columns

last date = maxx(filter(Table, Table[Code] = earlier(Table[Code])&& Table[region] = earlier(Table[region]) && Table[Date] < earlier(Table[Date])),Table[Date])

difference = Table[score] - maxx(filter(Table,  Table[Code] = earlier(Table[Code])&& Table[region] = earlier(Table[region])  && Table[Date] = earlier(Table[last date])),Table[score])

 

As new measures

Last Day Non Continous = CALCULATE(sum('Table'[score]),filter(all('Date'),'Date'[Date] =MAXX(FILTER(all('Date'),'Date'[Date]<max('Date'[Date])),'Table'['DAte'])))

Change = sum('Table'[score])- [Last Day Non Continous]

 

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
AllisonKennedy
Super User
Super User

You could try doing this as a column using EARLIER and RANK if you want the difference between the current and previous date for each Code > Region.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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