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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
TBoat
Frequent Visitor

Multi-conditional find replace in Data Power Query from two seperate columns

Hi,

 

I have an issue with some of the data being miss classified in my report. I am trying to find a solution on the Power Bi side instead of changing it in the data base. In Power Query does anyone know how to do a "Find and Replace" very specifically based off multiple columns?

 

Here is my issue:

 

Can I sort in Specifically in Power Query by Chart Acct Number Name column 4450 - Other - Consignment and change the column Chart Acct find and replace with in this example a 05 - Other Wholesale to 04 - Consignment?

 

I can't do this in Dax off these two columns because they are already written in Dax to get to this point and are based off a sort order in the original Database.

 

If I could go in and change the I think this could be done in Power Query with M language or not sure. Can I do this in Power Query before messing with the data with DAX? Does anyone have suggestions?

 

Thanks so much!

 

T

 

"Find Replace" Chart Acct"Find Replace" Chart Acct

 

 

 

 

7 REPLIES 7
TBoat
Frequent Visitor

Thanks for your help on this. @lbendlin 

 

My report is acting and refreshing so slow now with just a few changes. Is there any way to cut down on the refresh / load time of these new items? I only have 2 million rows too...

You can instead opt to add a calculated column in DAX. That will be faster as it happens in memory.

 

The replacer function is likely not the source of your slowness as it only works on row level.  You probably have other expensive transforms like sorting or merging.  Those should be avoided.

lbendlin
Super User
Super User

Absolutely.  Replacer.ReplaceValue is actually a function placeholder that you can replace (no pun intended) with your own (x,y,z) function to do all kinds of wonderful things.

 

Please provide sanitized sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

Hi - @lbendlin  

 

Thanks for getting back to me. Interesting. I would like to see how this function works in Power Query. I attached a sample of what my data looks like:Multiple Column Find Replace.png

 

 

In this case I would like to Replace cg_sort_order " 7 " with " 8 " - only if ca_AcctNumber is "4650"and da_AcctNumber is "4191".

 

Thanks so much for your help!

 

Trevor

 

 

please provide the sample data in usable format. I can't work with screenshots.

Here is a simple version.  For more complex scenarios you can write a custom replacer function.

Table.ReplaceValue(Source,each [cg_sort_order],each if [cg_sort_order]="7" and [ca_AcctNumber]="4650" and [da_AcctNumber]="4191" then "8" else [cg_sort_order],Replacer.ReplaceValue,{"cg_sort_order"})

see attached.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.