Forum Discussion
Bergh
4 years agoHelper II
Date issue
Hi. I have a date column that takes away 9 days. [date] -9, but I would not like to include Saturday and Sunday. Only working days / weekdays.
- 4 years ago
ea_minus_9 = VAR Period = 9 VAR EndDate = TableName[ea] RETURN IF ( NOT ISBLANK ( EndDate ), VAR StartDate = EndDate - 2 * Period VAR DatesPeriod = CALENDAR ( StartDate, EndDate ) VAR DatesAndWDs = ADDCOLUMNS ( DatesPeriod, "@WorkingDay", VAR DayOfWeek = WEEKDAY ( [Date], 2 ) RETURN IF ( DayOfWeek IN { 6, 7 }, "No", "Yes" ) ) VAR WDsOnly = FILTER ( DatesAndWDs, [@WorkingDay] = "Yes" ) VAR TopNTable = TOPN ( Period + 1, WDsOnly, [Date], DESC ) RETURN MINX ( TopNTable, [Date] ) )
ValtteriN
4 years agoCommunity Champion
Hi,
One way to do this is to add the following column in your calendar table:
Working days before today = IF(and(and(WEEKDAY('Calendar'[Date],2)<>6,WEEKDAY('Calendar'[Date],2)<>7),[date]<=TODAY()),1,0)
Then simply use these as a filter:
Then simply use these as a filter:
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/