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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
obriaincian
Resolver I
Resolver I

PowerBi - Counting Switch Statements

Hi All,

I have the following measure:

test = SWITCH(TRUE(),
MAX(test[month])>=9&&MAX(test[month])<=12,"fall",
MAX(test[month])>=1&&MAX(test[month])<=3,"winter",
MAX(test[month])>=4&&MAX(test[month])<=6,"spring",
MAX(test[month])>=7&&MAX(test[month])<=8,"summer")

 

 

Currently it looks at the month number (i.e. "3" for March and outputs "winter", what I'd like however is it to output is a count per season to show the distribution of the seasons in the dataset.

For example my desired output would be

 

Month Number       Count of occurrences of each season
fall      5
winter      7
spring      9
summer      11

 

I can't have a calculated column here either as I will want to make this measure dynamic later on with the use of a slicer, can someone tell me if this is possible?

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @obriaincian 

 

You can first add a table with season values in it. Just like below.

vjingzhang_0-1657103386283.png

 

Then create the following measure to count the occurrences. [test] is your original measure. 

Measure = COUNTX(FILTER(test,[test]=SELECTEDVALUE(Seasons[Season])),test[month])

vjingzhang_1-1657103509928.png

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @obriaincian 

 

You can first add a table with season values in it. Just like below.

vjingzhang_0-1657103386283.png

 

Then create the following measure to count the occurrences. [test] is your original measure. 

Measure = COUNTX(FILTER(test,[test]=SELECTEDVALUE(Seasons[Season])),test[month])

vjingzhang_1-1657103509928.png

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

exactly what I was looking for, thanks

amitchandak
Super User
Super User

@obriaincian , You can create a table with these values and join that with a measure in filter using table or values/summarize in a new measure

 

refer to the example. In place of a numeric table, you need a text table

Dynamic segmentation -Measure to Dimension conversion: https://youtu.be/gzY40NWJpWQ

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.