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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
ArchStanton
Impactful Individual
Impactful Individual

Switch Function Not Working

Hi,

 

The following code only brings back the ELSE parameter 9, I can't work out why?

 

RANK2 Sort = SWITCH(
            TRUE(),
                'Cases'[Age Profile2] = "0-3 Mths",1,
                'Cases'[Age Profile2] = "3-6 Mths",2,
                'Cases'[Age Profile2] = "6-9 Mths",3,
                'Cases'[Age Profile2] = "9-12 Mths",4,
                'Cases'[Age Profile2] = "12-15 Mths",5,
                'Cases'[Age Profile2] = "15-18 Mths",6,
                'Cases'[Age Profile2] = "18-21 Mths",7,
                'Cases'[Age Profile2] = "21-24 Mths",8,
                9)
                
       

 

The Age Profile Column my Sort Column is referencing is here:

 

Age Profile2 = 
if( 'Cases'[Case Length (Validation Date)] < 90.25 , " 0-3 Mths",
    if('Cases'[Case Length (Validation Date)] < 182.5, " 3-6 Mths",
        if('Cases'[Case Length (Validation Date)] < 273.75, " 6-9 Mths", 
            if('Cases'[Case Length (Validation Date)] < 365.25, " 9-12 Mths", 
                if('Cases'[Case Length (Validation Date)] < 456.25, " 12-15 Mths",
                   if('Cases'[Case Length (Validation Date)] < 547.5, " 15-18 Mths", 
                      if('Cases'[Case Length (Validation Date)] < 638.75, " 18-21 Mths", 
                         if('Cases'[Case Length (Validation Date)] < 730, " 21-24 Mths",
                         "24+ Mths"))))))))

 

Any ideas why this is going wrong?

Thanks

1 ACCEPTED SOLUTION
MAwwad
Solution Sage
Solution Sage

Hello,

 

 

Try to copy paste the same value exactly as SWITCH Is case sensitive, I see some spaces in your values 

example : 

" 0-3 Mths"

 

While in your switch function: 

"0-3 Mths"

 

So I dont think its considering them the same values.

 

 

Please accept this as a solution if it helped you 🙂

View solution in original post

2 REPLIES 2
MAwwad
Solution Sage
Solution Sage

Hello,

 

 

Try to copy paste the same value exactly as SWITCH Is case sensitive, I see some spaces in your values 

example : 

" 0-3 Mths"

 

While in your switch function: 

"0-3 Mths"

 

So I dont think its considering them the same values.

 

 

Please accept this as a solution if it helped you 🙂

ArchStanton
Impactful Individual
Impactful Individual

Yes, thanks, the answer was starring me in the face!

Much appreciated!!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors