Forum Discussion
If This Month or This Week falls in Selected Date Ranges
- 9 years ago
Hi Bird007,
It seems that creating a date dimension would already solve part of the difficulty that you're having here.
But RobJo found a possible solution that might help you out directly. Can you check this out and let us know if it is applicable for you?
We discussed this issue in the "Global Power BI - Forum Aid" event.
Come join us at the new Microsoft pbiusergroup.com board for more info, help and fun & informative events
- 9 years ago
You could try creating the following table which expands the leave date ranges and provides you the ability to count/sum the weekdays
Leave Table = SELECTCOLUMNS( FILTER( CROSSJOIN('Leave',Dates) , 'Leave'[FromDate] <= 'Dates'[Date] && 'Leave'[ToDate] >= 'Dates'[Date] ), "EmployeeID" , [EmployeeID], "Absense Type", [AbsenceType] , "From Date" , [FromDate] , "To Date" , [ToDate] , "Date on Leave" , [Date] , "Is Weekday" , SWITCH( WEEKDAY('Dates'[Date],3), --- Saturday --- 5,0, --- Sunday --- 6,0, --- ELSE --- 1 ) )
Hi Bird007,
It seems that creating a date dimension would already solve part of the difficulty that you're having here.
But RobJo found a possible solution that might help you out directly. Can you check this out and let us know if it is applicable for you?
We discussed this issue in the "Global Power BI - Forum Aid" event.
Come join us at the new Microsoft pbiusergroup.com board for more info, help and fun & informative events
- Phil_Seamark9 years agoMicrosoft Employee
You could try creating the following table which expands the leave date ranges and provides you the ability to count/sum the weekdays
Leave Table = SELECTCOLUMNS( FILTER( CROSSJOIN('Leave',Dates) , 'Leave'[FromDate] <= 'Dates'[Date] && 'Leave'[ToDate] >= 'Dates'[Date] ), "EmployeeID" , [EmployeeID], "Absense Type", [AbsenceType] , "From Date" , [FromDate] , "To Date" , [ToDate] , "Date on Leave" , [Date] , "Is Weekday" , SWITCH( WEEKDAY('Dates'[Date],3), --- Saturday --- 5,0, --- Sunday --- 6,0, --- ELSE --- 1 ) )- Birdjo9 years agoResolver II
Thanks to both of you!
I tried both and accepted Phil_Seamark's solution because it excluded the weekends.
Of course there's a simple way to exclude the weekands with the first solution, but Phil_Seamark's seems complete to me.
Thanks again!