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
powerbiuser101
Advocate I
Advocate I

How to replace text based on filter?

I'm trying to write a query to replace text but only based on values of another column. Example:

 

MainSideDrinkPrice
Burger Soda5.00
 FriesSoda2.00
BurgerFriesSoda7.00
Salad  2.50
SaladApple 3.00

 

I want to replace the blanks in [Drink] with "Orange Juice" only if [Main] = "Salad" and [Side] = "Apple". Using the GUI and simply replacing texts didn't help me since it still filled all the blanks in [Drink]. Not sure how to procede and I'd rather avoid creating a calculated column

1 ACCEPTED SOLUTION
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @powerbiuser101,

 

1. In the Query Editor, right click the blanks in the column Drink, then select Replace Values. Enter 1 to the Replace with.

How_to_replace_text_based_on_filter1

2. Open the Advanced Editor. Replace the 1 with the code below.

each if [Main] = "Salad" and [Side] = "Apple" then "Orange Juice" else " "

How_to_replace_text_based_on_filter2

 

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.

View solution in original post

3 REPLIES 3
hiralsoni_001
Frequent Visitor

Hi there,

 

I am trying to replace values in a column where if value is M is replaced by Para Assement and when its 17 it should be replaced with Master's Degree, but when I replace M by Para Assement then it also replaces and overrites all values in 17 as 'Para Assementaster's Degree'.

 

How to correct this now. Please help

Thanks.

v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @powerbiuser101,

 

Could you please mark the proper answer as the solution?

 

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
Microsoft Employee
Microsoft Employee

Hi @powerbiuser101,

 

1. In the Query Editor, right click the blanks in the column Drink, then select Replace Values. Enter 1 to the Replace with.

How_to_replace_text_based_on_filter1

2. Open the Advanced Editor. Replace the 1 with the code below.

each if [Main] = "Salad" and [Side] = "Apple" then "Orange Juice" else " "

How_to_replace_text_based_on_filter2

 

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.

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.