Forum Discussion
Anonymous
6 years agoNot applicable
Dax formula for Last Thursday
Hey Guys,
I have a date table and I need to get a formula to get a custom date, such as last Thursday or Monday. Tried WEEKNUM function with max operator as well, did not seem wokring.
Can you please help.
Thanks,
Sona
Hi Anonymous
you need smth like
Measure = CALCULATE(MAX(Table[Date]), Table[Date]<TODAY(), WEEKDAY(Table[Date])=4)
4 Replies
- Greg_Deckler
Community Champion
Well, if I had a date table and I needed to get last Thursday in a column for example for each date, I would probaby do something along the lines of:
Last Thursday Column = VAR __Date = 'Calendar'[Date] VAR __Weeknum = WEEKNUM(__Date) VAR __PreviousWeekNum = __Weeknum - 1 RETURN MAXX(FILTER('Calendar',WEEKNUM([Date]) = __PreviousWeekNum && WEEKDAY([Date]) = 5),[Date]) - az38
Community Champion
Hi Anonymous
you need smth like
Measure = CALCULATE(MAX(Table[Date]), Table[Date]<TODAY(), WEEKDAY(Table[Date])=4)- AnonymousNot applicable
It worked great. Thanks a lot.
- camargos88
Community Champion
Hi Anonymous ,
Try this code:
Monday = CALCULATE(MAX('Date'[Date]); FILTER(ALL('Date'); 'Date'[Date] < MAX('Date'[Date]) && WEEKDAY('Date'[Date]; 1) = 2))If you need change the day, just change WEEKDAY('Date'[Date]; 1) = 2 (Starting from Sunday = 1).Ricardo