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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

For each date return the value for previous day

Hello, I am trying to create a file that for each date it will return data from a previous day. I would like it to logically verify whether the previous date is a weekend or holiday and ignore those, then return the previous working day. I am attempting to attach my pbix file. Need to find where to do that.

 

For example, in the below table I would like to return the column [High] and [Low] of the previous working day for the current date. I have been racking my brain trying to figure this out but it seems to be beyond me. Let me know if I can provide more infoCapture.JPG

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous Try:

Column High = 
  VAR __Date = [Date]
  VAR __PrevDate = MAXX(FILTER('Table', [Date] < __Date && ( [Day] <> "Saturday" || [Day] <> "Saturday" ) ), [Date])
  VAR __Result = MAXX( FILTER( 'Table', [Date] = __PrevDate ), [High])
RETURN
  __Result


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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , You can join date of your table with date of a date table and use time intelligence

 

example

 

Day behind Sales = CALCULATE(SUM(Table[Open),dateadd('Date'[Date],-1,Day))
Day behind Sales = CALCULATE(SUM(Table[Open]),previousday('Date'[Date]))

 

In case you need a column

 

Sumx(filter(Table, Table[Symbol] = earlier(Table[Symbol])  && Table[Date] = earlier(Table[Date]) -1 ), [Open])

 

Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c3243d1f9

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

@amitchandak That doesn't account for holidays and weekends. Need to do a double lookup.



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Community Champion
Community Champion

@Anonymous Try:

Column High = 
  VAR __Date = [Date]
  VAR __PrevDate = MAXX(FILTER('Table', [Date] < __Date && ( [Day] <> "Saturday" || [Day] <> "Saturday" ) ), [Date])
  VAR __Result = MAXX( FILTER( 'Table', [Date] = __PrevDate ), [High])
RETURN
  __Result


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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors