Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hi All,
I have an option to choose in filters years, months or weeks, depending what users need.
How can I create a measure to count weeks selected? for example if the user selects 'January to March', the measure will show 13 weeks or when the user selects just 2 weeks in week slicer, the measure will show 2, etc.
I have 3 slicers from the same dim date table:
Happy to change the layout if it is better to do the measure, for example:
Please support.
Thank you!
Solved! Go to Solution.
Provide demo file and another DAX for reference:
WkCount =
VAR _MinYear = MIN('Calendar'[Date].[Year])
VAR _MaxYear = MAX('Calendar'[Date].[Year])
VAR _MinMonth = MIN('Calendar'[Month])
VAR _MaxMonth = MAX('Calendar'[Month])
VAR _MinWeek = MIN('Calendar'[Week])
VAR _MaxWeek = MAX('Calendar'[Week])
RETURN
CALCULATE( DISTINCTCOUNT('Calendar'[Year_Week]),
FILTER(ALL('Calendar'),
'Calendar'[Date].[Year] >= _MinYear && 'Calendar'[Date].[Year] <= _MaxYear &&
'Calendar'[Month] >= _MinMonth && 'Calendar'[Month] <= _MaxMonth &&
'Calendar'[Week] >= _MinWeek && 'Calendar'[Week] <= _MaxWeek))
Best Regards,
Joyce
Provide demo file and another DAX for reference:
WkCount =
VAR _MinYear = MIN('Calendar'[Date].[Year])
VAR _MaxYear = MAX('Calendar'[Date].[Year])
VAR _MinMonth = MIN('Calendar'[Month])
VAR _MaxMonth = MAX('Calendar'[Month])
VAR _MinWeek = MIN('Calendar'[Week])
VAR _MaxWeek = MAX('Calendar'[Week])
RETURN
CALCULATE( DISTINCTCOUNT('Calendar'[Year_Week]),
FILTER(ALL('Calendar'),
'Calendar'[Date].[Year] >= _MinYear && 'Calendar'[Date].[Year] <= _MaxYear &&
'Calendar'[Month] >= _MinMonth && 'Calendar'[Month] <= _MaxMonth &&
'Calendar'[Week] >= _MinWeek && 'Calendar'[Week] <= _MaxWeek))
Best Regards,
Joyce
@A_a_a Convert your Year slicer also as range kind of slicer similar to Month & Week slicers and then use this DAX, it might help:
TotalSelectedWeeks =
VAR MinSelectedYear = MIN('Date'[Year])
VAR MaxSelectedYear = MAX('Date'[Year])
VAR MinSelectedMonth = MIN('Date'[Month])
VAR MaxSelectedMonth = MAX('Date'[Month])
VAR MinSelectedWeek = MIN('Date'[Week])
VAR MaxSelectedWeek = MAX('Date'[Week])
RETURN
CALCULATE(
COUNTROWS('Date'),
('Date'[Year] >= MinSelectedYear || ISBLANK(MinSelectedYear)) && ('Date'[Year] <= MaxSelectedYear || ISBLANK(MaxSelectedYear)),
('Date'[Month] >= MinSelectedMonth || ISBLANK(MinSelectedMonth)) && ('Date'[Month] <= MaxSelectedMonth || ISBLANK(MaxSelectedMonth)),
('Date'[Week] >= MinSelectedWeek || ISBLANK(MinSelectedWeek)) && ('Date'[Week] <= MaxSelectedWeek || ISBLANK(MaxSelectedWeek))
)
If you find this insightful, please provide a Kudo and accept this as a solution.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
89 | |
88 | |
82 | |
64 | |
49 |
User | Count |
---|---|
125 | |
111 | |
88 | |
69 | |
66 |