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
Shea1
Frequent Visitor

If statement

Hello, I am trying to write an if statement for a custom column.

 

What I am trying to do is say, if (table name) = (numeric value) then ("text value").

 

I am working with Dataverse data sources. My reasoning behind this is because one field is stored as type "choices". This means that I am given a numeric value rather than the string value that PowerApps can read. 

I have 19 of these numeric to string value's so if you could show me how to use the else if also that would be great.

 

I need the string value for visualizations.

 

Thank you, I am happy to answer any questions. 

Capture.PNG

1 ACCEPTED SOLUTION
johncolley
Solution Sage
Solution Sage

Hi @Shea1 ,

 

There's a few ways to get around dataverse not providing the labels to you. I suggest looking at https://markcarrington.dev/2021/03/09/optionset-labels-in-power-bi-reports/ or here if you are fimilar with the xrmtoolbox https://www.xrmtoolbox.com/plugins/GapConsulting.PowerBIOptionSetAssistant/ 

 

If you want to continue down the column path - please note that Custom Columns in Power Query are written in M not DAX which is used in Calculated Columns and Measures so the syntax required is different. 

 

You could create a calculated column using switch:

Newcolmun = 
SWITCH(cr666_correctioncomments, 
826100000, "Data reprocessing",
826100001, "Option2",
etc)

View solution in original post

3 REPLIES 3
Shea1
Frequent Visitor

Hey John, all I needed to do was put quotations around the numeric ID's and the string value, thanks mate

johncolley
Solution Sage
Solution Sage

Hi @Shea1 ,

 

There's a few ways to get around dataverse not providing the labels to you. I suggest looking at https://markcarrington.dev/2021/03/09/optionset-labels-in-power-bi-reports/ or here if you are fimilar with the xrmtoolbox https://www.xrmtoolbox.com/plugins/GapConsulting.PowerBIOptionSetAssistant/ 

 

If you want to continue down the column path - please note that Custom Columns in Power Query are written in M not DAX which is used in Calculated Columns and Measures so the syntax required is different. 

 

You could create a calculated column using switch:

Newcolmun = 
SWITCH(cr666_correctioncomments, 
826100000, "Data reprocessing",
826100001, "Option2",
etc)

Hi @johncolley, thank you for getting back to me.

 

I tried using the Switch statement and I got the error:
"Function 'SWITCH' does not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values."

 

Currently the TDS endpoint is blocked by a firewall, so that is not an option

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.

Top Solution Authors