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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Qotsa
Helper V
Helper V

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
Mariusz
Community Champion
Community Champion

Hi @Qotsa 

 

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 @Qotsa 

 

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


 

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

Mariusz
Community Champion
Community Champion

Hi @Qotsa 

 

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

 

Perfect. Thank you.

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.