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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
chrisjames10
Regular Visitor

Making a calculated column with two values from different days by state

Hello!

 

I'm trying to figure out how to make a column in my table that displays the difference between the Allocated values (by state) from one day to the next. My table is updating daily with new data so ideally the column reflects the difference between the total allocated from that state on the current day and the total allocated from that state on the previous day. 

 

Thanks!! 

 

 

Screenshot 2022-09-15 164914.png

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@chrisjames10 

maybe you can try this

column = 
var _last=maxx(FILTER('Table','Table'[state]=EARLIER('Table'[state])&&'Table'[date]=EARLIER('Table'[date])-1),'Table'[alllocated])
return 'Table'[alllocated]-_last

1.PNG





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

Proud to be a Super User!




View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@chrisjames10 See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
ryan_mayu
Super User
Super User

@chrisjames10 

maybe you can try this

column = 
var _last=maxx(FILTER('Table','Table'[state]=EARLIER('Table'[state])&&'Table'[date]=EARLIER('Table'[date])-1),'Table'[alllocated])
return 'Table'[alllocated]-_last

1.PNG





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

Proud to be a Super User!




Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors