Forum Discussion
aashton
Helper V
3 years agoCount total dates from slicer, filtering out weekends
Hello, I have a report that has a date slicer allowing a user to select a date range. I also have a Weekend Flag filter, choices are Weekday, Weekend or All, allowing them to choose which days to i...
aashton
Helper V
3 years agoThank you yes, that looks like it will work. But I need the filter do be dependent on what they pick on the Weekend Flag filter, so I can't hardcode it just for weekdays:
FreemanZ
Super User
3 years agohi aashton
then try like:
Total Days =
VAR _FirstDay =
CALCULATE(
MIN('Case Details'[Surgery Date]),
ALLSELECTED('Case Details'[Surgery Date])
)
VAR _LastDay =
CALCULATE(
MAX('Case Details'[Surgery Date]),
ALLSELECTED('Case Details'[Surgery Date])
)
VAR _WeekendFlag =
SELECTEDVALUE(DateTable[Weekend Flag])
RETURN
COUNTROWS(
FILTER(
ALL(DateTable),
DateTable[Date]>=_FirstDay
&&DateTable[Date]<=_LastDay
&&DateTable[Weekend Flag] = _WeekendFlag
)
)
p.s. consider @someone to continue a discussion.
- aashton3 years ago
Helper V
FreemanZ Thank you so much for your help. Sorry one more thing...what if they pick both Weekend and Weekday because they want to see everyday?
- FreemanZ3 years ago
Super User
hi aashton
if the user doesn't pick any item in the slicer, the measure shall calculate for everyday.
- aashton3 years ago
Helper V
FreemanZ Ohhhh...I must have done something wrong, it's not working like that:
Total Days =VAR FirstDay = CALCULATE(MIN('Case Details'[Surgery Date]),ALLSELECTED('Case Details'[Surgery Date]))VAR LastDay = CALCULATE(MAX('Case Details'[Surgery Date]),ALLSELECTED('Case Details'[Surgery Date]))VAR _WeekendFlag=SELECTEDVALUE(dim_date[Weekend Flag])RETURNCOUNTROWS(FILTER(ALL(dim_date),dim_date[act_date]>=FirstDay && dim_date[act_date]<=LastDay && dim_date[Weekend Flag]=_WeekendFlag))