Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Count selected options in slicer

I have a slicer that sets restricts data for month(s) in my report:

monthslicer.PNG

 

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:

VAR January = IF(ISFILTERED('Date'[MonthYearName]) = "January 2020", 1,0)
VAR February = IF(ISFILTERED('Date'[MonthYearName]) = "February 2020", 1,0)
VAR March = IF(ISFILTERED('Date'[MonthYearName]) = "March 2020", 1,0)
VAR April = IF(ISFILTERED('Date'[MonthYearName]) = "April 2020", 1,0)
VAR May = IF(ISFILTERED('Date'[MonthYearName]) = "May 2020", 1,0)
VAR June = IF(ISFILTERED('Date'[MonthYearName]) = "June 2020", 1,0)
VAR July = IF(ISFILTERED('Date'[MonthYearName]) = "July 2020", 1,0)
VAR August = IF(ISFILTERED('Date'[MonthYearName]) = "August 2020", 1,0)
VAR September = IF(ISFILTERED('Date'[MonthYearName]) = "September 2020", 1,0)
VAR October = IF(ISFILTERED('Date'[MonthYearName]) = "October 2020", 1,0)
VAR November = IF(ISFILTERED('Date'[MonthYearName]) = "November 2020", 1,0)
VAR December = IF(ISFILTERED('Date'[MonthYearName]) = "December 2020", 1,0)*/

VAR MonthSum = January+February+March+April+May+June+july+August+September+October+November+December
RETURN MonthSum
 
If this is do-able, can it also be made so that the text doesn't have to include '2020'? If contains "January", then that is True. 
 
 
2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community 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.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

v-gizhi-msft
Community Support
Community 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:

30.PNG

When you select same month from different year, it shows the count of select value regardless of year:

31.PNG

Here is my test pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto Zhi

View solution in original post

2 REPLIES 2
v-gizhi-msft
Community Support
Community 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:

30.PNG

When you select same month from different year, it shows the count of select value regardless of year:

31.PNG

Here is my test pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto Zhi

Greg_Deckler
Community Champion
Community 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.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors