<?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 a substring with selected value in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-a-substring-with-selected-value/m-p/3079394#M107230</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="484976" data-lia-user-login="AviramWeiss" class="lia-mention lia-mention-user"&gt;AviramWeiss&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Make sure you are fitering the Customer Name from the customer table. Also double check interactions.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Feb 2023 11:47:21 GMT</pubDate>
    <dc:creator>tamerj1</dc:creator>
    <dc:date>2023-02-14T11:47:21Z</dc:date>
    <item>
      <title>Replacing a substring with selected value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-a-substring-with-selected-value/m-p/3079325#M107226</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm creating a personalized letter in Power BI desktop (have to do it using this, because of client's demand...).&lt;/P&gt;&lt;P&gt;I have a customer table (lets say it has only 2 columns: custID and custName), and an independant text-parts table that composes the letter.&lt;/P&gt;&lt;P&gt;In these text-parts, there are place-holders for parameters. They look like "[param-name]".&lt;/P&gt;&lt;P&gt;For this example, I have 2 types of place-holders: [year] and [custName].&lt;/P&gt;&lt;P&gt;So a typical text-part could look like: "During the year of [year], the above-mentioned [custName] has purchased items..."&lt;/P&gt;&lt;P&gt;The report has to replace [year] with a fixed value (2022) and [custName] with a value from customers table, after filtering (page filter or slicer) only one customer.&lt;/P&gt;&lt;P&gt;I created another table, name "params", which holds 2022 as a value, and&amp;nbsp;&amp;nbsp;managed the [year] substitution well with:&lt;/P&gt;&lt;P&gt;substitute([text],"[year]",calculate(max('params'[value]),filter('params',[param]="year"))).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when trying to substitute with custName, I always get the unfiltered customer list.&lt;/P&gt;&lt;P&gt;Tried these, with no avail:&lt;/P&gt;&lt;P&gt;-&amp;nbsp;substitute([text],"[custName]",max('customers'[custName]))&lt;/P&gt;&lt;P&gt;-&amp;nbsp;substitute([text],"[custName]",calculate(maxx('customers'[custName]),keepfilters(not(isblank('customers'[custName])))))&lt;/P&gt;&lt;P&gt;-&amp;nbsp;substitute([text],"[custName]",selectedvalue('customers'[custName]))&lt;/P&gt;&lt;P&gt;-&amp;nbsp;substitute([text],"[custName]",maxx(filter('customers',[custName]=selectedvalue('customers'[custName])),'customers'[custName]))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 10:54:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-a-substring-with-selected-value/m-p/3079325#M107226</guid>
      <dc:creator>AviramWeiss</dc:creator>
      <dc:date>2023-02-14T10:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing a substring with selected value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-a-substring-with-selected-value/m-p/3079394#M107230</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="484976" data-lia-user-login="AviramWeiss" class="lia-mention lia-mention-user"&gt;AviramWeiss&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Make sure you are fitering the Customer Name from the customer table. Also double check interactions.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 11:47:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-a-substring-with-selected-value/m-p/3079394#M107230</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-02-14T11:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing a substring with selected value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-a-substring-with-selected-value/m-p/3079797#M107279</link>
      <description>&lt;P&gt;Thank you,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;I'm using the same field, in the same table, to filter.&lt;/P&gt;&lt;P&gt;As for interactions - as far as I understand, there should be no relationship between the 2 tables, as the text-parts are not specific to a customer. I double checked, and there are no relationships (actually, the text-part table is stand-alone, and is not connected to any other table in the project).&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 15:21:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-a-substring-with-selected-value/m-p/3079797#M107279</guid>
      <dc:creator>AviramWeiss</dc:creator>
      <dc:date>2023-02-14T15:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing a substring with selected value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-a-substring-with-selected-value/m-p/3079844#M107282</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="484976" data-lia-user-login="AviramWeiss" class="lia-mention lia-mention-user"&gt;AviramWeiss&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Interactions are between slicers and visuals snd between different visuals. However, I don't think this is the problem. Can you please share some screenshots to clarify the picture?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 15:41:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-a-substring-with-selected-value/m-p/3079844#M107282</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-02-14T15:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing a substring with selected value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-a-substring-with-selected-value/m-p/3079922#M107290</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I apologize, but can't send a working file (network limitations...). Here are some screenshots. Hope they explain better than before:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my entire database:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I defined a new&amp;nbsp;&lt;STRONG&gt;column&lt;/STRONG&gt; in table phrases:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;calcYearSubstitute = SUBSTITUTE([phrase],"[year]","2022")&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;It works fine:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;As you can see, in both phrases 2 and 3, the substring [year] was replaced by 2022.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Added a single-choice slicer based on customers[custName], and defined another column in phrases:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;calcCustSubstitute = SUBSTITUTE([phrase],"[custName]",maxx('customers',[custName]))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No matter how I slice the customers, the substring [custName] in phrases 1 and 3 is always replaced by "Ringo" (alphabetic max of the customer list):&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I want the newly defined column &lt;FONT color="#0000FF"&gt;calcCustSubstitute&lt;/FONT&gt; to respond to the slicer on the page, so the substring [custName] would be replaced by "Paul" in this example, and any toher customer when slicing appropriately.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Aviram&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 16:27:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-a-substring-with-selected-value/m-p/3079922#M107290</guid>
      <dc:creator>AviramWeiss</dc:creator>
      <dc:date>2023-02-14T16:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing a substring with selected value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-a-substring-with-selected-value/m-p/3079941#M107293</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="484976" data-lia-user-login="AviramWeiss" class="lia-mention lia-mention-user"&gt;AviramWeiss&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the clear explanation. Calculated columns do not communicate with the filter context. This has to be a measure&lt;/P&gt;
&lt;P&gt;calcCustSubstitute =&lt;BR /&gt;SUBSTITUTE (&lt;BR /&gt;SELECTEDVALUE ( Phrases[phrase] ),&lt;BR /&gt;"[custName]",&lt;BR /&gt;SELECTEDVALUE ( customers[custName] )&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 16:40:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-a-substring-with-selected-value/m-p/3079941#M107293</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-02-14T16:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing a substring with selected value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-a-substring-with-selected-value/m-p/3080061#M107304</link>
      <description>&lt;P&gt;Thank you very much,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;Now it works like a charm.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2023 18:03:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-a-substring-with-selected-value/m-p/3080061#M107304</guid>
      <dc:creator>AviramWeiss</dc:creator>
      <dc:date>2023-02-14T18:03:28Z</dc:date>
    </item>
  </channel>
</rss>

