Forum Discussion
Count Working Days Excluding Weekend and Holidays
- 7 years ago
Sure. I added this measure as another value in the table you provided:
Working Days = COUNTROWS( FILTER( ALL(DateDimension), DateDimension[Day of Week] <> 5 && DateDimension[Day of Week] <> 6 && DateDimension[Is Public Holiday?] = "No" && DateDimension[Date] < SELECTEDVALUE(Data[Date Acknowledged]) && DateDimension[Date] >= SELECTEDVALUE(Data[Date Received]) ) )I wasn't sure whether to count the day it was acknowledged or the day it was received in the count, so I just picked one. For example, if an item was acknowledged and then received on the next day, should that be 1 (since one day has passed) or 2 (there have been 2 calendar days involved)? If it was acknowledged on Friday and recieved on Sunday, should that be 1(counting Friday) or 0 (since no business days have passed since acknowledgement)? Change the less than/greater than or equal to signs accordingly.
Sure. I added this measure as another value in the table you provided:
Working Days =
COUNTROWS(
FILTER(
ALL(DateDimension),
DateDimension[Day of Week] <> 5 && DateDimension[Day of Week] <> 6 &&
DateDimension[Is Public Holiday?] = "No" &&
DateDimension[Date] < SELECTEDVALUE(Data[Date Acknowledged]) &&
DateDimension[Date] >= SELECTEDVALUE(Data[Date Received])
)
)I wasn't sure whether to count the day it was acknowledged or the day it was received in the count, so I just picked one. For example, if an item was acknowledged and then received on the next day, should that be 1 (since one day has passed) or 2 (there have been 2 calendar days involved)? If it was acknowledged on Friday and recieved on Sunday, should that be 1(counting Friday) or 0 (since no business days have passed since acknowledgement)? Change the less than/greater than or equal to signs accordingly.
- parry2k7 years ago
Super User
PaulMac you can also try following measure
Days Count = VAR __dateTable = CALENDAR ( MAX ( Data[Date Received] ), MAX ( Data[Date Acknowledged] ) ) VAR __table = INTERSECT ( __dateTable, CALCULATETABLE ( VALUES ( DateDimension[Date] ), ALL ( DateDimension ), DateDimension[Is Public Holiday?] = "No", DateDimension[Day of Week] <= 4 ) ) RETURN COUNTROWS ( __table ) - PaulMac7 years ago
Helper IV
CmcmahanYou! Are! A! Star!
Now, is there a way I can tweak your DAX measure to do the samething but as a custom column in Power Query?
Many thanks
PaulMc
- Cmcmahan7 years ago
Resident Rockstar
You can create calculated columns with DAX, no need to involve Power Query. https://docs.microsoft.com/en-us/power-bi/desktop-tutorial-create-calculated-columns
All you should need to do is to replace SELECTEDVALUE in the above query with EARLIER, due to the different context.