cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Lmendes
Frequent Visitor

Replace values

Hello

I am struggling with two things to do with replacing values. 

 

https://www.dropbox.com/s/0j792l4jlkfsigr/Replace%20values.pbix?dl=0

https://www.dropbox.com/s/vvedv43zubsptxh/Replace%20value%20issue.xlsx?dl=0 

 

1. I need to do a conditional replace values. In the linked examples (one pbix file and one excel) i would like to say;

 

If {Q1,Q2,Q3} = "Not at all" then 0 else 1 - but I have no idea how to write this in 'm' language. 

 

2. I have data whereby the response is spelt wrongly or with CAPs in some answers and lowercase in others. Is there a way in m language the below

 

If {Do you agree with this rating?} = "Yes" or "yes" or "y" then 1 else 0

 

I have attached a sample file - I am not very well versed in m language so if you can make the solution user friendly it will be greatly appreciated!

Laura

1 ACCEPTED SOLUTION

@Lmendes solution is attached, check power query replace steps.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

7 REPLIES 7
raja_pandian
Regular Visitor

I've replaced the value from "Aptiv" to "Karnataka"

 

But for some reason, I can still see "Aptiv" , similar to these there are many other values didnt change. Not sure why it didnt change.

 

I used Advanced Editor to change, I have provided the below code for your reference.

 

#"Replaced Value82" = Table.ReplaceValue(#"Replaced Value81","Aptiv ","Karnataka",Replacer.ReplaceText,{"State/Province"}),

 

Also another state name "Andhra Pradesh" repeating twice, I have used trimmed and clean columns before replacing the value but still no changes. Can somebody provide some inputs on this please.

 

it should work

in any case you have another option. is to create a dataset with 2 columns, nameold and namenew and then in dax create a new column like finalname that check the newname



Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Thanks for your quick response. Appreciate your solution. However, For some reason, I can still see the same result.

dobregon
Impactful Individual
Impactful Individual

In powerBI you can do using the commands automatically.

 

In the query editor window you have the option in tab transform to "replace values". you need to do

- Select the column that you want to analyze
- Click on replace columns
- Write the condition

Maybe you need to do this for each condition that you have. Automatically the powerbi will write this in the M query.

Same for second point



Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Hi

 

Thanks so much for your advice. I am familiar with the replace values step unfortunately I have to do this for several columns and responses so it would take me quite a while. It would be much more efficent for me to be able to replace one value and use else for all others.

 

Thank you

Laura

@Lmendes solution is attached, check power query replace steps.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Brilliant thanks so much!

 

Just a pointer for learners (like me). I had to include [Q3] as [#"Q3"] and [Q2] as [#"Q2"] etc.... for it to work. But it now works like a dream 🙂

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors