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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Anonymous
Not applicable

Switch statement - else text value

Hi,

 

Below Switch statement works for me but I need to include else then the result is a text value.

 

So

If 'powerbi114 cmQualifications'[qualificationId] = 3892 or 4036 or 4038 then

Expiry Date = "Does not Expire"

 

Anyway I can modify below Switch to include this?

 

Expiry Date =
SWITCH(
TRUE(),
'powerbi114 cmQualifications'[qualificationId] = 3892,DATEADD('powerbi114 cmQualifications'[awardDate].[Date],3,YEAR),
'powerbi114 cmQualifications'[qualificationId] = 4036,DATEADD('powerbi114 cmQualifications'[awardDate].[Date],2,YEAR),
'powerbi114 cmQualifications'[qualificationId] = 4038,DATEADD('powerbi114 cmQualifications'[awardDate].[Date],3,YEAR))
1 ACCEPTED SOLUTION

Hi @Anonymous 

 

Sorry, my bad, all your conditions result in number and your else is text.

You will need to convert all the values you return to text using CONVERT() or FORMAT( 1, "") or return number in ELSE condition

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

4 REPLIES 4
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Else is the last argument like

Expiry Date =
SWITCH(
TRUE(),
'powerbi114 cmQualifications'[qualificationId] = 3892,DATEADD('powerbi114 cmQualifications'[awardDate].[Date],3,YEAR),
'powerbi114 cmQualifications'[qualificationId] = 4036,DATEADD('powerbi114 cmQualifications'[awardDate].[Date],2,YEAR),
'powerbi114 cmQualifications'[qualificationId] = 4038,DATEADD('powerbi114 cmQualifications'[awardDate].[Date],3,YEAR),
"ELSE SOMTHING")

 

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn


 

Anonymous
Not applicable

Thanks for reply.

I should have said I tried that but getting this error - Expressions that yield variant data-type cannot be used to define calculated columns.

 

fhjy.jpg

Hi @Anonymous 

 

Sorry, my bad, all your conditions result in number and your else is text.

You will need to convert all the values you return to text using CONVERT() or FORMAT( 1, "") or return number in ELSE condition

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Anonymous
Not applicable

Perfect. Thank you.

Helpful resources

Announcements
Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.