Forum Discussion
Count selected options in slicer
I have a slicer that sets restricts data for month(s) in my report:
I want to create a measure that counts the amount of options selected.
If January and February are chosen, that's 2.
I tried the following but it gave an error about comparing True/False with Text:
Measure MonthSlicerCount:
Measure = COUNTROWS(VALUES('Date'[MonthYearName]))
Please note, only using VALUES here because it makes sense to use VALUES. Don't just go throwing VALUE or VALUES into every DAX calculation randomly. This is not for you Anonymous but I've been seeing a lot of needless use of VALUE and VALUES lately. So, when I use it, I want to make sure that people understand that there is a purpose behind it.
Hi,
Please try to create a column first:
Month = 'Table'[Date].[Month]The try this measure:
Measure = DISTINCTCOUNT('Table'[Month])When you select differet month from different year, it shows:
When you select same month from different year, it shows the count of select value regardless of year:
Here is my test pbix file:
Hope this helps.
Best Regards,
Giotto Zhi
2 Replies
- Greg_DecklerCommunity Champion
Measure = COUNTROWS(VALUES('Date'[MonthYearName]))
Please note, only using VALUES here because it makes sense to use VALUES. Don't just go throwing VALUE or VALUES into every DAX calculation randomly. This is not for you Anonymous but I've been seeing a lot of needless use of VALUE and VALUES lately. So, when I use it, I want to make sure that people understand that there is a purpose behind it.
- v-gizhi-msftCommunity Support
Hi,
Please try to create a column first:
Month = 'Table'[Date].[Month]The try this measure:
Measure = DISTINCTCOUNT('Table'[Month])When you select differet month from different year, it shows:
When you select same month from different year, it shows the count of select value regardless of year:
Here is my test pbix file:
Hope this helps.
Best Regards,
Giotto Zhi