<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Replacing values in multiple columns based on condition in Power Query in Power Query</title>
    <link>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/2114075#M62320</link>
    <description>&lt;P&gt;Hi ziying,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for adding the clarification. I could imagine in my head that happens. I'm just stumbled by how you thought of doing this, please help me understand.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No where does it say that Y represents the Table function, or that the third parameters should be the Z or what X should do.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I can ask&lt;/P&gt;&lt;P&gt;1. How did you come up with this in the first place? Is there any documentation on this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. In theory, you could have replaced the function letters with any other letter, correct?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Rick&lt;/P&gt;</description>
    <pubDate>Mon, 04 Oct 2021 14:41:07 GMT</pubDate>
    <dc:creator>Rickmaurinus</dc:creator>
    <dc:date>2021-10-04T14:41:07Z</dc:date>
    <item>
      <title>Replacing values in multiple columns based on condition in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/1288779#M41009</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table like this:&lt;/P&gt;&lt;TABLE border="4"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; &amp;nbsp; plan&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;unplan&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;internal&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;external&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;production&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;day flag&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/1/2020&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;TD&gt;70&lt;/TD&gt;&lt;TD&gt;6000&lt;/TD&gt;&lt;TD&gt;Production Day&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/2/2020&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;Non-Production Day&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/3/2020&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;1300&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;Down Day&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/4/2020&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;80&lt;/TD&gt;&lt;TD&gt;5000&lt;/TD&gt;&lt;TD&gt;Production Day&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/5/2020&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;120&lt;/TD&gt;&lt;TD&gt;150&lt;/TD&gt;&lt;TD&gt;1000&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;Down Day&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/6/2020&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;Non-Production Day&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/7/2020&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;Non-Production Day&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if [day flag] = "Down Day" then replace [plan], [unplan], [internal] and [external] columns with null, else keep original values.&lt;/P&gt;&lt;P&gt;The result like this:&lt;/P&gt;&lt;TABLE border="4"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;plan&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;unplan&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;internal&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;external&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;production&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;day flag&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/1/2020&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;TD&gt;70&lt;/TD&gt;&lt;TD&gt;6000&lt;/TD&gt;&lt;TD&gt;Production Day&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/2/2020&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;Non-Production Day&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/3/2020&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;null&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;null&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;null&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;null&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;1300&lt;/TD&gt;&lt;TD&gt;Down Day&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/4/2020&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;80&lt;/TD&gt;&lt;TD&gt;5000&lt;/TD&gt;&lt;TD&gt;Production Day&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/5/2020&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;null&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;null&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;null&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#0000FF"&gt;null&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;1000&lt;/TD&gt;&lt;TD&gt;Down Day&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/6/2020&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;Non-Production Day&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/7/2020&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;Non-Production Day&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use code:&lt;/P&gt;&lt;P&gt;#"Replaced Value1" = Table.ReplaceValue(Source, each [plan], each if [day flag] = "Down Day" then null else [plan],Replacer.ReplaceValue,{"plan"}),&lt;BR /&gt;#"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1",each [unplan], each if [day flag] = "Down Day" then null else [unplan], Replacer.ReplaceValue,{"unplan"}),&lt;BR /&gt;#"Replaced Value3" = ...&lt;/P&gt;&lt;P&gt;#"Replaced Value4" = ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you see, I have to repeat same logic 4 times for replace values of&amp;nbsp;[plan], [unplan], [internal] and [external] columns. Actually, in my table, there are 20 columns need do that. I don't want to repeat this logic 20 times.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering if any better solution for my situation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 22:38:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/1288779#M41009</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-11T22:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values in multiple columns based on condition in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/1288784#M41010</link>
      <description>&lt;P&gt;You can include multiple columns in the list. This is a text replacement. Just add more columns in the list brackets {}&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Table.ReplaceValue(#"Filtered Rows","a","g",Replacer.ReplaceText,{"Stock Item", "Color", "Selling Package"})&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 22:44:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/1288784#M41010</guid>
      <dc:creator>edhans</dc:creator>
      <dc:date>2020-08-11T22:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values in multiple columns based on condition in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/1289155#M41017</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on the simulated data source and the data processing logic you provided, write the query code like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;= Table.ReplaceValue(Source, each [day flag]="Down Day", null, (x,y,z)=&amp;gt; if y then z else x, List.Range(Table.ColumnNames(Source),1,4))&lt;/LI-CODE&gt;&lt;P&gt;&lt;FONT face="arial black,avant garde" color="#FF0000"&gt;If my code solves your problem, mark it as a solution&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 02:47:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/1289155#M41017</guid>
      <dc:creator>ziying35</dc:creator>
      <dc:date>2020-08-12T02:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values in multiple columns based on condition in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/1289795#M41025</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As what is suggested by&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="227922" data-lia-user-login="ziying35" class="lia-mention lia-mention-user"&gt;ziying35&lt;/a&gt;&amp;nbsp;, I created data to reproduce your scenario. The pbix file is attached in the end.&lt;/P&gt;
&lt;P&gt;Table:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may insert a new step as below. On your side, you may add all corresponding columns in {"plan","unplan","internal","external",...}.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;= Table.ReplaceValue(Source, each [day flag]="Down Day", null, (x,y,z)=&amp;gt; if y then z else x, List.Select(Table.ColumnNames(#"Changed Type"),
each  List.Contains( {"plan","unplan","internal","external"},_)
)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Allan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial',sans-serif;"&gt;If this post &lt;STRONG&gt;&lt;SPAN style="font-family: 'Arial',sans-serif;"&gt;helps&lt;/SPAN&gt;&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;I&gt;&lt;SPAN style="font-family: 'Arial',sans-serif;"&gt;Accept it as the solution&lt;/SPAN&gt;&lt;/I&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 08:40:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/1289795#M41025</guid>
      <dc:creator>v-alq-msft</dc:creator>
      <dc:date>2020-08-12T08:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values in multiple columns based on condition in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/1291203#M41068</link>
      <description>&lt;P&gt;Thank you very much! Your demostration is really very helpful for understanding the code. It works on my end!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 17:11:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/1291203#M41068</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-12T17:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values in multiple columns based on condition in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/2098362#M61857</link>
      <description>&lt;P&gt;Another way to do it, is the unpivot your columns, and then on the newly created column apply a conditional replace operation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;= Table.ReplaceValue(
     #"Changed Type",
     each [Value],
     each if [day flag] = "Down Day" then null else [Value],
     Replacer.ReplaceValue,{"Value"}
 )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can find the details on the conditional replace right here:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://gorilla.bi/power-query/replace-values/#conditionally-replace-values" target="_blank" rel="noopener"&gt;https://gorilla.bi/power-query/replace-values/#conditionally-replace-values&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;--------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;I&gt;@ me in replies or I'll lose your thread&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Master Power Query M? &lt;/STRONG&gt;-&amp;gt; &lt;A href="https://powerquery.how" target="_blank"&gt;https://powerquery.how&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Read in-depth articles? &lt;/STRONG&gt;-&amp;gt; &lt;A href="https://gorilla.bi" target="_blank"&gt;BI Gorilla&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Youtube Channel: &lt;/STRONG&gt;&lt;A href="https://www.youtube.com/channel/UCxc-6L_IdxVphs4fn6cVeEQ" target="_blank"&gt;BI Gorilla&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this post helps, then please consider accepting it as the solution to help other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 16:32:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/2098362#M61857</guid>
      <dc:creator>Rickmaurinus</dc:creator>
      <dc:date>2023-07-25T16:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values in multiple columns based on condition in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/2098367#M61859</link>
      <description>&lt;P&gt;Hey ziying35.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I included your solution in my blogpost at&amp;nbsp;&lt;A href="https://gorilla.bi/power-query/replace-values/" target="_blank"&gt;https://gorilla.bi/power-query/replace-values/&lt;/A&gt;.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;However, I'm accustomed to working with Replacer.ReplaceValues and Replacer.ReplaceText. I don't fully understand your example.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you elaborate on the inner workings of :&amp;nbsp;&lt;/P&gt;&lt;P&gt;(x,y,z)=&amp;gt; if y then z else x?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Warm regards,&lt;/P&gt;&lt;P&gt;Rick&lt;/P&gt;</description>
      <pubDate>Sun, 26 Sep 2021 10:10:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/2098367#M61859</guid>
      <dc:creator>Rickmaurinus</dc:creator>
      <dc:date>2021-09-26T10:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values in multiple columns based on condition in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/2101452#M61939</link>
      <description>&lt;P&gt;x = original value&lt;/P&gt;
&lt;P&gt;y = match condition&amp;nbsp; (true or false)&lt;/P&gt;
&lt;P&gt;z = replacement value&lt;/P&gt;</description>
      <pubDate>Mon, 27 Sep 2021 23:45:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/2101452#M61939</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2021-09-27T23:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values in multiple columns based on condition in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/2102124#M61963</link>
      <description>&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b"&gt;&lt;SPAN&gt;Simple understanding: the second parameter of the function Table.ReplaceValue is represented by y, the third parameter is represented by z, and the replaced element itself is represented by x&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 06:55:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/2102124#M61963</guid>
      <dc:creator>ziying35</dc:creator>
      <dc:date>2021-09-28T06:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values in multiple columns based on condition in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/2114075#M62320</link>
      <description>&lt;P&gt;Hi ziying,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for adding the clarification. I could imagine in my head that happens. I'm just stumbled by how you thought of doing this, please help me understand.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No where does it say that Y represents the Table function, or that the third parameters should be the Z or what X should do.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I can ask&lt;/P&gt;&lt;P&gt;1. How did you come up with this in the first place? Is there any documentation on this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. In theory, you could have replaced the function letters with any other letter, correct?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Rick&lt;/P&gt;</description>
      <pubDate>Mon, 04 Oct 2021 14:41:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/2114075#M62320</guid>
      <dc:creator>Rickmaurinus</dc:creator>
      <dc:date>2021-10-04T14:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values in multiple columns based on condition in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/2114136#M62322</link>
      <description>&lt;P&gt;You can replace it with any string you want.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;(original,logiccheck,alternative)=&amp;gt; if logiccheck then alternative else original&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yes, the documentation is a bit sparse on this.&amp;nbsp; Here's a slight hint:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://docs.microsoft.com/en-us/powerquery-m/replacer-replacevalue" target="_blank"&gt;Replacer.ReplaceValue - PowerQuery M | Microsoft Docs&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It's misleading, but at least it mentions parameters &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have a suspicion that this approach can be used for other M functions as well.&amp;nbsp; Didn't have time to test it yet.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Oct 2021 14:57:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/2114136#M62322</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2021-10-04T14:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values in multiple columns based on condition in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/2128713#M62837</link>
      <description>&lt;P&gt;1. this use, I also happened to see in other places, I can not remember the place,.&lt;BR /&gt;2. Yes, there is nothing wrong, you can use any other&amp;nbsp;letters instead&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 06:00:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/2128713#M62837</guid>
      <dc:creator>ziying35</dc:creator>
      <dc:date>2021-10-12T06:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values in multiple columns based on condition in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/3785239#M124798</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="227922" data-lia-user-login="ziying35" class="lia-mention lia-mention-user"&gt;ziying35&lt;/a&gt;&amp;nbsp;, Sorry for pinging you on this old topic. This method works perfectly if I just want to replace the value with a fixed value (null&amp;nbsp;@ 1&amp;nbsp;@2, etc). But what if I want to multiple the old value with 1000? For example if the old value is 1000, instead of changing it to null i want to make it 1,000,000.&lt;/P&gt;&lt;P&gt;I tried changing the null to below, but it didn't work.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;each _ * 1000&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2024 07:56:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/3785239#M124798</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-03-22T07:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values in multiple columns based on condition in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/3785393#M124810</link>
      <description>&lt;P&gt;Figured it out minutes after asking this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;= Table.ReplaceValue(
   Source, 
   each [day flag]="Down Day", 
   each _, // this step become redundant, but needed to fill the syntax requirement
   // (x,y,z)=&amp;gt; if y then z else x, --- this is the original one, below is edited.
   (x,y,z)=&amp;gt; if y then x*1000 else x,  // we just ignore z, and replace it with x*1000
   List.Range(Table.ColumnNames(Source),1,4)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 22 Mar 2024 08:26:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/3785393#M124810</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-03-22T08:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing values in multiple columns based on condition in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/3785932#M124830</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;,&amp;nbsp;there are always many ways. Here you can find record base solution. I'm refering to 1st post sample data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMDJQ0lFSAAIQDcKmIMIcRJgZGICogKL8lNLkksz8PAWXxEqlWB2QViNsWpGxX36eLladxth0GoJtMgKThsZgyiW/HFmbCTZtxiDCAuJq3G41xWojWMTQFGo7FhvNyPaiOTk6YwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, #"    plan    " = _t, #"    unplan    " = _t, #"    internal    " = _t, #"    external    " = _t, #"    production     " = _t, #"    day flag    " = _t]),
    ColumnsTrim = Table.TransformColumnNames(Source, Text.Trim),
    ChangedType = Table.TransformColumnTypes(ColumnsTrim,{{"Date", type date}, {"plan", Int64.Type}, {"unplan", Int64.Type}, {"internal", Int64.Type}, {"external", Int64.Type}, {"production", Int64.Type}, {"day flag", type text}}),
    EnterColumnsToReplace = "plan, unplan, internal, external",
    ColsList = List.Transform(Text.Split(EnterColumnsToReplace, ","), Text.Trim),
    Ad_Replaced = Table.AddColumn(ChangedType, "Replaced", each 
        if [day flag] = "Down Day" then Record.Combine({_, Record.TransformFields(Record.SelectFields(_, ColsList), List.Transform(ColsList, (y)=&amp;gt;  {y, (x)=&amp;gt; x * 1000}))}) else _,
  type record ),
    Replaced = Table.FromRecords(Ad_Replaced[Replaced], Value.Type(ChangedType))
in
    Replaced&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2024 10:53:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Replacing-values-in-multiple-columns-based-on-condition-in-Power/m-p/3785932#M124830</guid>
      <dc:creator>dufoq3</dc:creator>
      <dc:date>2024-03-22T10:53:39Z</dc:date>
    </item>
  </channel>
</rss>

