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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
AmaGreen
Frequent Visitor

Switch.. True gives error when I save my Power BI file

Dear Community, 
I am having an issue with my Switch True function.
I want to create a string column out of an integer column.
The DAX functio is seen below.
It works fine and I can use it to develop my visuals. 

Age_range = SWITCH( True(),
'Main practice adopted'[Age_in_adopt] = BLANK() , " ",
'Main practice adopted'[Age_in_adopt] <18, "Young",
'Main practice adopted'[Age_in_adopt] >= 18 && 'Main practice adopted'[Age_in_adopt] <=35, "Youth",
'Main practice adopted'[Age_in_adopt] >=35, "Old")


The issue: when I click on the "Save"button to close my Power BI desktop, I get an error;
The syntax for '"Young"' is incorrect. (DAX(SWITCH( True(),'Main practice adopted'[Age_in_adopt] = BLANK() , " ",'Main practice adopted'[Age_in_adopt] <18. "Young",'Main practice adopted'[Age_in_adopt] >= 18 && 'Main practice adopted'[Age_in_adopt] <=35. "Youth",'Main practice adopted'[Age_in_adopt] >=35. "Old"))).

I tried using IF functions too, the same error happened.
Kindly help me on how to go about the error.
Thank you

1 ACCEPTED SOLUTION

@AmaGreen Well, it is indeed strange. I recreated the data and the column and no issues saving. What versino of the Desktop are you on? I attached my PBIX, perhaps you can open it and try saving it and see if you get the error?

 



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
AmaGreen
Frequent Visitor

@Greg_Deckler I am sharing the data file with you.
Due to confidentailty, I cannot share the file publicly.
Thanks for understanding.

Select_benefic.registered_yearSelect_benefic.pull_genderSelect_benefic.pull_dateSelect_benefic.pull_idcode_noteSelect_benefic.pull_idAdoptPractices.AdoptedpractAdoptPractices.NoadoptionAdoptPractices.essentpractiseAdoptPractices.essentialpract_numbAdoptPractices.two_morepracticeAdoptPractices.whataddoptedAdoptPractices.whataddopted_numbAdoptPractices.whatadopted_otherAdoptPractices.whataddopted_numb_noteAdoptPractices.practicesoneareaAdoptPractices.whatadd_note_numberAdoptPractices.practice_countGender_in_adoptGender_adoptedAge_in_adoptAge_range
 Male03/10/2023 12:06:30  Yes Use_of_improved_seeds1YesManual_ploughing Sowing_compass_and_density_(intercropping_spacing)2  Yes  MaleMale33Youth
2023Male26/10/2023 08:55:37  Yes integrated_pest_mgt1NoDrip_irrigation Irrigation_with_sprinklers2  No 2Male 49Old
OtherMale03/10/2023 12:06:30 3701184870140No  0  0     Female 40Old
 Male03/10/2023 12:06:30  Yes water_management Use_of_improved_seeds Crop_rotation3YesUse_of_pedestral_pump_for_irrigation Transport_by_open_channel_to_the_field Transport_by_closed_channel_(pipes)_to_the_field3  Yes      
2023Female26/10/2023 09:31:28  Yes mulching integrated_pest_mgt2YesManual_ploughing Ploughing_with_animal_traction Land_preparation_with_sulches3  Yes  FemaleFemale38Old

@AmaGreen Well, it is indeed strange. I recreated the data and the column and no issues saving. What versino of the Desktop are you on? I attached my PBIX, perhaps you can open it and try saving it and see if you get the error?

 



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thank you.
I copied and pasted yours.
I don't know why it didnt work for me.
I use Power BI desktop version: 2.124.2028.0 64-bit (December 2023)

@AmaGreen Yep, that's the same one I use. Super weird.



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

@AmaGreen That's very strange. Any chance you can share the PBIX file?



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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