<?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: Check if rows contain a string value against an unrelated table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Check-if-rows-contain-a-string-value-against-an-unrelated-table/m-p/2821501#M89580</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="452252" data-lia-user-login="sohrabsa" class="lia-mention lia-mention-user"&gt;sohrabsa&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a calculated column in table 2&lt;/P&gt;
&lt;P&gt;SUMX (&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FILTER ( Table1, CONTAINSSTRING ( Table1[Description], Table2[transaction] ) ),&lt;/P&gt;
&lt;P&gt;Table1[Amount]&lt;BR /&gt;)&lt;/P&gt;</description>
    <pubDate>Thu, 06 Oct 2022 03:27:06 GMT</pubDate>
    <dc:creator>tamerj1</dc:creator>
    <dc:date>2022-10-06T03:27:06Z</dc:date>
    <item>
      <title>Check if rows contain a string value against an unrelated table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Check-if-rows-contain-a-string-value-against-an-unrelated-table/m-p/2821359#M89572</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two tables in my dataset:&lt;/P&gt;&lt;P&gt;Table1 is my transactions which have a description that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;and Table2 is my legend table, where I define what each transaction belong to what category:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal is to categorize each transaction based on the legend by looking for a piece of description column in the transaction column. So if a transaction contains "Desk", the column I'm going to create shows "Office Supplies".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I've tried:&lt;/P&gt;&lt;P&gt;I used a new custom column in Table 1 to check for 3 values and return true if they returned a value:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;List.Transform ( {"Desk", "Payroll", "Chair"}, (substring) =&amp;gt; Text.Contains([Description], substring))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This returns a list of TRUE or FALSE based on the three examples I gave it. Potentially this can be used to get the first row that returns true and use that as a reference for the second column?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to do it in Excel, and essentially I had to use SEARCH fonction with INDEX and MATCH to get the category from a different table. My issue is that I have two tables that are not related and I'm not sure how to do a search for a piece of string for every row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm pretty new to PowerBI and I need some support please.&lt;/P&gt;&lt;P&gt;TIA!&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 02:07:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Check-if-rows-contain-a-string-value-against-an-unrelated-table/m-p/2821359#M89572</guid>
      <dc:creator>sohrabsa</dc:creator>
      <dc:date>2022-10-06T02:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: Check if rows contain a string value against an unrelated table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Check-if-rows-contain-a-string-value-against-an-unrelated-table/m-p/2821501#M89580</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="452252" data-lia-user-login="sohrabsa" class="lia-mention lia-mention-user"&gt;sohrabsa&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a calculated column in table 2&lt;/P&gt;
&lt;P&gt;SUMX (&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FILTER ( Table1, CONTAINSSTRING ( Table1[Description], Table2[transaction] ) ),&lt;/P&gt;
&lt;P&gt;Table1[Amount]&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 03:27:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Check-if-rows-contain-a-string-value-against-an-unrelated-table/m-p/2821501#M89580</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-10-06T03:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Check if rows contain a string value against an unrelated table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Check-if-rows-contain-a-string-value-against-an-unrelated-table/m-p/2821525#M89582</link>
      <description>&lt;LI-CODE lang="markup"&gt;let
    Legend = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkisLMrPyVHSUQpOzEksqlSK1YlWcs5IzCwCCvmnpWUmpyoElxYU5GSmFoPlXFKLs3FIOefn5mYWF2fm56EZl5+WlpqKQ5NTfl5pMZL6WAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Txn = _t, Category = _t]),
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("LctBCoAgEADAv+zZw7pr4TO6i8SaQZEkaR36fQZeB8Y50MRxrQeTBgUaEbxyQGwmeUtOSXNj6iwiyyZ7CUxNuevfzRBrI9MJMeTzqfNV7qajteD9Bw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Desc = _t, Amount = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Desc", type text}, {"Amount", Int64.Type}}),
    Categorized = let txn = Legend[Txn], cat = Legend[Category] in Table.AddColumn(#"Changed Type", "Cat.", each cat{List.PositionOf(txn, [Desc], 1, (x,y) =&amp;gt; Text.Contains(y,x,Comparer.OrdinalIgnoreCase))})
in
    Categorized&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 04:03:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Check-if-rows-contain-a-string-value-against-an-unrelated-table/m-p/2821525#M89582</guid>
      <dc:creator>CNENFRNL</dc:creator>
      <dc:date>2022-10-06T04:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: Check if rows contain a string value against an unrelated table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Check-if-rows-contain-a-string-value-against-an-unrelated-table/m-p/2824130#M89724</link>
      <description>&lt;P&gt;This does the job!&amp;nbsp;&lt;/P&gt;&lt;P&gt;At first, I was confused by your first two lines, but then I realized that's just the way you loaded the data. For me it was from an Access Database and an Excel sheet.&lt;BR /&gt;&lt;BR /&gt;Essentially the formula I used is:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; Categorized = let txn = Legend[Txn], cat = Legend[Category] in Table.AddColumn(#"Changed Type", "Cat.", each cat{List.PositionOf(txn, [Desc], 1, (x,y) =&amp;gt; Text.Contains(y,x,Comparer.OrdinalIgnoreCase))})&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then I had to change "Legend" with the latest table and the latest columns.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 23:09:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Check-if-rows-contain-a-string-value-against-an-unrelated-table/m-p/2824130#M89724</guid>
      <dc:creator>sohrabsa</dc:creator>
      <dc:date>2022-10-06T23:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Check if rows contain a string value against an unrelated table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Check-if-rows-contain-a-string-value-against-an-unrelated-table/m-p/2824131#M89725</link>
      <description>&lt;P&gt;This also worked, but it was not exactly what I was looking for. Thank you for your time!&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 23:10:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Check-if-rows-contain-a-string-value-against-an-unrelated-table/m-p/2824131#M89725</guid>
      <dc:creator>sohrabsa</dc:creator>
      <dc:date>2022-10-06T23:10:37Z</dc:date>
    </item>
  </channel>
</rss>

