Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi
I read in a blog that you can conditionally replace values in a column.
= Table.ReplaceValue(#"Filtered Rows",each [CATEGORY DETAIL],each if ([CATEGORY]="CAR" and Text.Contains([PRODUCTS],"@"))=true then "BLUE CAR" else if [CATEGORY]="CAR" and Text.Contains([PRODUCTS],"@")=false then "RED CAR" else [CATEGORY DETAIL],Replacer.ReplaceText,{"CATEGORY DETAIL"})
Example of entries are
CATEGORY: CAR
PRODUCTS: This is a car@
CATEGORY DETAIL: random text
Does anyone know why the conditional replacement does not work?
Solved! Go to Solution.
Hi @dats ,
syntax looks alright to me at first sight.
Please be aware that Power Query is case sensitive.
Also, you could try the change the replacer function from Replacer.ReplaceText to Replacer.ReplaceValue.
Also, make sure to clean and trim the CATEGORY-column.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi, @dats
I have done test with the data and M code you provided. It works well.
Is the dashboard working well a live page pinned to it and the one with no changes a visual pinned it?
Best Regards,
Caiyun Zheng
Hi @dats ,
syntax looks alright to me at first sight.
Please be aware that Power Query is case sensitive.
Also, you could try the change the replacer function from Replacer.ReplaceText to Replacer.ReplaceValue.
Also, make sure to clean and trim the CATEGORY-column.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
@Greg_Deckler I don't think so. It worked in another dashboard with the exact same syntax which is why I am wondering that power bi doesn't replace the values accordingly nor returns an error
@dats - Wouldn't you need a Replacer.ReplaceText for each of the if statements? And wouldn't you need to use all 3 arguments? @ImkeF
Replacer.ReplaceText - PowerQuery M | Microsoft Docs
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.