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

Combine replace value steps?

Me again,

 

I am combining steps to clean up my Query Editor. E.g. Renaming columns all in one step rather than all over the shop. 

I want to combine Table.ReplaceValue steps but it doesn't seem to want to. I assume you cannot do this for some reason, but if you know how then please let me know. 

 

I tried copying one of my replace values onto the end of another, separated by a comma with the parenthesis wrapping all of it. 

This didn't work. 

 

 

8 REPLIES 8
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

Could you please mark the proper answers as solutions?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

I would suggest you provide a dummy pbix file. We can give you a solution with details in the file. If you'd like to share a file, you can upload it to the cloud drive like OneDrive, GoogleDrive, then share the download link here. Please don't share sensitive data here.

 

Best Regards,
Dale

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



Hi Dale,

 

Sorry for the delay in response.

 

I cannot attach the dataset but I have screenshots of what i'm talking about. 

So I have 20 Replaced Value steps. 

 

I had about the same number of steps for Renamed Columns and Changed Type, and I was able to combine these steps into one single step each using M-Query in the formula bar by using curly brackets and coma separators. 

 

I want to do the same for the Replaced Value steps. However applying the same logic as I did for the Renamed Columns steps, does not work for Replaced Value. 

 

So to summarise, I am wondering if it is possible to combine 'Replaced Value' Applied Steps using M-Query in the formula bar. 

 


Example of where I have combined multiple steps of renaming columns by splitting using {},Example of where I have combined multiple steps of renaming columns by splitting using {},First Replace Value StepFirst Replace Value StepSecond Replace Value StepSecond Replace Value StepThird Replace Value StepThird Replace Value StepApplied steps shows all the Replaced Value StepsApplied steps shows all the Replaced Value Steps

Hi @Anonymous,

 

@PattemManohar's solution works. Please check out the demo in the attachment.

Combine-replace-value-steps

 

Best Regards,
Dale

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

@Anonymous It is possible, Please try this...

 

Renaming Mutliple columns in single step:

 

  #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Product", "Product1"}, {"Tank", "Tank1"}, {"Inventor", "Inventor1"}}),

Mutliple Replace values in single step:

 

    #"AllReplace" = [#"DIESEL" = "DIESEL1",#"REG" = "REG1"],
    #"Replaced Value" = Table.TransformColumns(#"Renamed Columns",{{"Product1",each Record.FieldOrDefault(AllReplace,_,_)}})




Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Greetings @PattemManohar 

 

is there a way to read #"DIESEL" and "DIESEL1" from columns of another table?

 

so that there is a replacements table?

 

Anonymous
Not applicable

Hi there Pattem,

 

I can't figure this out. 

 

In the step i've pasted below I am is replacing </font> with blank. (some crazy formatting was pulled into my BI report)

My next replace would be for example <font> with blank

After that I want to replace <font face> with blank

 

In total, I have 20 replaced values. I want them all in one step. Below is the first step, if you can show me what to type instead of what is below, I can probably follow. I'm just getting used to Power BI and Query Editor still!

 

= Table.ReplaceValue(#"Replaced Value","</font>","",Replacer.ReplaceText,{"Claim ID/Invoice_x00"})

@Anonymous Please provide some sample data so that I can provide you the exact steps as per that. Meanwhile, I'll make it clear about the steps I've provided 

 

    #"AllReplace" = [#"DIESEL" = "DIESEL1",#"REG" = "REG1"],
    #"Replaced Value" = Table.TransformColumns(#"Renamed Columns",{{"Product1",each Record.FieldOrDefault(AllReplace,_,_)}})

In Advanced Editor, I've added a #"AllReplace" which contains a list of old and new values (DIESEL is old value and DIESEL1 is new value to get replaced. Similarly, REG is an old value and REG1 will be a new value)

 

Then add an another step, where I've used this list. You need to use "Table.TransformColumns" if you want to do all search and replace in single step but not "Table.ReplaceValue" 





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




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.