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
Adam01
Advocate I
Advocate I

Return 10 days Ago from Yesterday where [Is Business Day] = 1

Hi All!

 

I have a query that requires me to return the date 10 days ago from yesterday where it only counts Business Days and skips weekends, bank holidays etc.

 

For Example, yesterdays date was "03/11/2022", I would need the measure to calculate the previous 10 days before this where it is ONLY a business day, so in theory this should return "21/10/2022" as this was 10 Business Days ago, however the below DAX returns "24/10/2022" so this is clearly counting Non Business Days.

 

VAR LastDateExpr = LASTDATE ( 'Calendar'[Date] )          <- Always set to be Yesterdays Date
VAR CalcExpr =
CALCULATE (
    DATEADD ( LastDateExpr , -10, DAY ),
       'Calendar'[IsBusinessDay] = 1
       )
RETURN
    CalcExpr
 
I am unsure where to go from here
1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Adam01 Maybe:

Measure = 
  VAR LastDateExpr = LASTDATE ( 'Calendar'[Date] )
  VAR __Table = FILTER('Calendar',[Date] <= LastDateExpr && [Date] >= LastDateExpr - 14 && WEEKDAY([Date],2) < 6)
  VAR __Table1 = ADDCOLUMMNS(__Table, "__DaysAgo", COUNTROWS(FILTER(__Table,[Date] >= EARLIER([Date]))))
  VAR CalcExpr = MAXX(FILTER(__Table1, [__DaysAgo] = 10),[Date])
RETURN
    CalcExpr


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

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@Adam01 Maybe:

Measure = 
  VAR LastDateExpr = LASTDATE ( 'Calendar'[Date] )
  VAR __Table = FILTER('Calendar',[Date] <= LastDateExpr && [Date] >= LastDateExpr - 14 && WEEKDAY([Date],2) < 6)
  VAR __Table1 = ADDCOLUMMNS(__Table, "__DaysAgo", COUNTROWS(FILTER(__Table,[Date] >= EARLIER([Date]))))
  VAR CalcExpr = MAXX(FILTER(__Table1, [__DaysAgo] = 10),[Date])
RETURN
    CalcExpr


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 Thank you! This works for what I need!

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.