Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
Hello
I would like to optimize the code of power query when I do search / replace
In a date field I process 3 types of modifications in a row and I would like to make these 3 modifications on a single line of code
#"Filtered rows4" = Table.SelectRows(#"Replaced errors", each true),
#"Replaced Value3" = Table.ReplaceValue(#"Filtered Lines4",null, "12/31/2050",Replace.ReplaceValue,{"Theoretical Date Lease End"}),
#"ReplacedValue4" = Table.ReplaceValue(#"ReplacedValue3", "SO", "12/31/2050",Replacer.ReplaceText,{"Theoretical End of Lease Date"}),
#"Replaced Value5" = Table.ReplaceValue(#"Replaced Value4", "cf SM", "12/31/2050",Replacer.ReplaceText,{"Theoretical Date Lease End"}),
#"Replaced Value6" = Table.ReplaceValue(#"Replaced Value5", "cf CAS", "12/31/2050",Replacer.ReplaceText,{"Theoretical Date Lease End"}),
My proposal that doesn't work for the moment
= List.ReplaceValue(#"ReplacedValue3", "SO", "cf CAS", "cf SM", "31/12/2050",Replacer.ReplaceText,{"Theoretical End of Lease Date"})
Obviously it only takes my 3 fields to replace
Thanks for your help
#"Filtered rows4" = Table.SelectRows(#"Replaced errors", each true),
this line is nothing but gibberish.
#"Replaced Value3" = Table.ReplaceValue(#"Filtered Lines4",each [Theoretical Date Lease End], each if List.Contains({null, "cf CAS", "cf SM"}, [Theoretical Date Lease End]) then "12/31/2050" else [Theoretical Date Lease End], Replace.ReplaceValue, {"Theoretical Date Lease End"}),
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@Anonymous
You add the following step after #"Filtered rows4" step
Table.TransformColumns(#"Filtered Lines4", {{"Channel", each if List.Contains({"SO", "cf CAS", "cf SM"},_) then "12/31/2050" else _, type text}})
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group