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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
tcallender007
Frequent Visitor

Switch Statement not working to create a new column

I want to create a new column in my data, based off the value of an existing column.  I did not want to use an if statement, because would have to use about 9 nested statements and that is soooooo messy.  So after a little googling I found the Switch statement.

  • The switch statement seemed pretty straight forward so I went with it
  • The statement below looks right to me, but it is only evaluating the last line (in other words it sets everything to [Client Name]

Thanks in advance for your assistance

 

Client Name Modified= SWITCH (PMO_Time[Project Number],

“2700002","Finance Non-Project",

"2700003","Finance Non-Project",

"2700004","Finance Non-Project",

"2700006","Finance Non-Project",

"2700007","Finance Non-Project",

"2700008","Finance Non-Project",

"2700011","Finance Non-Project",

"2700012","Finance Non-Project",

"2700999","Finance Non-Project",

PMO_Time[Client Name]

)

 

1 ACCEPTED SOLUTION
jdobrzen
Advocate II
Advocate II

Maybe try trimming PMO_Time[Project Number], just in case there's a space or something in front/behind it.  Maybe it needs to be padded with zeros or something else?

View solution in original post

4 REPLIES 4
jdobrzen
Advocate II
Advocate II

Maybe try trimming PMO_Time[Project Number], just in case there's a space or something in front/behind it.  Maybe it needs to be padded with zeros or something else?

Thank you.  That was it and easy to fix.. once you pointed me in the correct direction.

jthomson
Solution Sage
Solution Sage

Is the data type of your project number field a number or text? If it's the former try getting rid of the "s around your project numbers

Thanks for your reply.  The data type is text.  Additionally, PowerBi does not return any errors when I save the statement. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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