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
Anonymous
Not applicable

DAX measure change string

Hello, 

I am trying to create a DAX measure (cannot be calculated column - I am using live connection to AAS) to change string values in a column.  So, for example, I have a column with abbreviations like "CHN" that the users wants to instead see "China" for.  I have written switch statements using Switch/true in the past for the same purpose but for some reason I cannot get it to work now.  Please help thank you 🙂

6 REPLIES 6
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create a measure like

Measure = SWITCH(MAX('4111'[Region]),"we","China",MAX('4111'[Region]))

6.png

 

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you @v-juanli-msft.  I actually did end up writing a similar switch statement - I wrote mine a bit differently using hasonevalue and values, but same idea.  

 

Problem is - and I think this applies to both your measure and mine - it's dependent on context so it really only works if I include it with the column that I am changing the name from.   This isn't very helpful if I want to include it in on the x axis or legend -  though I believe that is a limitation of measures in general.  Ultimately I think this is one of those cases that ideally is done in a column instead of a measure.  In the meantime I have given the user a "legend" which is a table that shows original column and column with the desired corresponding text.  

 

But if you know of a way to make the measure perform like a column I'd love to hear it 🙂 I am running into a lot of walls with AAS live connection.

jbrijalba
Helper I
Helper I

I have ran into the same issue using SWITCH and IF in a measure. Have you tried going to Edit Queries and using the Replace Values function?

 Replace.PNG

Anonymous
Not applicable

@jbrijalbacannot edit queries with AAS live connection, unfortunately.

@Anonymous , sorry about that. I have never used that connection before. Is that why you cannot make a calculated column?

Anonymous
Not applicable

@jbrijalbayup AAS live connection disables many features - including query editor.

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