<?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: Count rows containing one of many strings (not exactly) in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-containing-one-of-many-strings-not-exactly/m-p/2431047#M64697</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;You need to put all the conditions into the formula.&amp;nbsp;There doesn't seem to be a simpler way.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you can put the conditions into a column. Then count the column.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column = if(CONTAINSSTRING('specialties'[specialty_name  ], "Cloud") || CONTAINSSTRING('specialties'[specialty_name  ], "Data"),1,0)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Measure = CALCULATE(COUNT(Specialties[Column])+0,FILTER(ALL('Table'),'Table'[Company_id  ]=SELECTEDVALUE('Table'[Company_id  ])))&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;If I have misunderstood your meaning, please provide your pbix file without privacy infromation and desired output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Community Support Team _ Polly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Apr 2022 05:49:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-04-01T05:49:25Z</dc:date>
    <item>
      <title>Count rows containing one of many strings (not exactly)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-containing-one-of-many-strings-not-exactly/m-p/2424741#M64368</link>
      <description>&lt;P&gt;&lt;U&gt;Context:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Table1 = 'Companies' (list of companies)&lt;/P&gt;&lt;P&gt;Table2 = 'Specialties' (list of areas of expertise of those companies)&lt;/P&gt;&lt;P&gt;Relationship = 1:M (one company has multiple specialties)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Company_id&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Company_name&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Microsoft&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Google&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;Amazon&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Specialty_id&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Specialty_name&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Company_id&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Cloud&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Data&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;Database&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;System Architecture&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;Security&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a column in the table 'Companies' that counts the amount of specialties of that company containing one of many strings. In other words, the column 'Specialty_name' has to be filtered so that only the rows remain that contains one of the strings (not exact).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;List of strings = {"Data", "Cloud", ...}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the output should be:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Company_id&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Company_name&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Count_Specialties&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Microsoft&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Google&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;Amazon&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you see, the new column should also count "Database" even though that exact string is not in the list (only "Data").&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far, I managed to create a DAX but it's very long and inefficient:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;Count_Specialties= CALCULATE(COUNTROWS(FILTER('specialties', CONTAINSSTRING('specialties'[specialty_name], "Cloud") || CONTAINSSTRING('specialties'[specialty_name], "Data") + 0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000"&gt;The list contains 20+ strings, so the DAX keeps adding strings via || (and at the end I add '+ 0' to avoid&amp;nbsp;&lt;EM&gt;null&lt;/EM&gt; values).&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000"&gt;I wonder if there is another way that can produce the same column more efficiently.&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000"&gt;Thanks in advance!&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 30 Mar 2022 07:36:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-containing-one-of-many-strings-not-exactly/m-p/2424741#M64368</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-30T07:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Count rows containing one of many strings (not exactly)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-containing-one-of-many-strings-not-exactly/m-p/2424938#M64378</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;You can do this via the data model by either a measure or a new table. Please see two tables (different ways of calculating the same result) and a measure doing the same thing. Please see link here:&lt;/P&gt;&lt;P&gt;&lt;A title="Tech_Specialties" href="https://drive.google.com/file/d/1EcZBdUDVUC0cOb3CSM1QdnblfbvZQzxL/view?usp=sharing" target="_self"&gt;https://drive.google.com/file/d/1EcZBdUDVUC0cOb3CSM1QdnblfbvZQzxL/view?usp=sharing&lt;/A&gt;&amp;nbsp;&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;</description>
      <pubDate>Tue, 29 Mar 2022 17:02:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-containing-one-of-many-strings-not-exactly/m-p/2424938#M64378</guid>
      <dc:creator>Whitewater100</dc:creator>
      <dc:date>2022-03-29T17:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: Count rows containing one of many strings (not exactly)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-containing-one-of-many-strings-not-exactly/m-p/2426063#M64432</link>
      <description>&lt;P&gt;Hey, thanks a lot for your response!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately don't think I was clear enough in the description. I have a big list of relevant Specialties on which I want to filter, but the amount of Specialties linked to the companies is much higher. So it's not enough to just count the specialties. I know the example I gave was misleading because all of the specialties needed to be counted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will edit the post, let me know if it still isn't clear!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hopefully you can still help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 07:34:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-containing-one-of-many-strings-not-exactly/m-p/2426063#M64432</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-30T07:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Count rows containing one of many strings (not exactly)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-containing-one-of-many-strings-not-exactly/m-p/2431047#M64697</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;You need to put all the conditions into the formula.&amp;nbsp;There doesn't seem to be a simpler way.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you can put the conditions into a column. Then count the column.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column = if(CONTAINSSTRING('specialties'[specialty_name  ], "Cloud") || CONTAINSSTRING('specialties'[specialty_name  ], "Data"),1,0)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Measure = CALCULATE(COUNT(Specialties[Column])+0,FILTER(ALL('Table'),'Table'[Company_id  ]=SELECTEDVALUE('Table'[Company_id  ])))&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;If I have misunderstood your meaning, please provide your pbix file without privacy infromation and desired output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Community Support Team _ Polly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 05:49:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-rows-containing-one-of-many-strings-not-exactly/m-p/2431047#M64697</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-01T05:49:25Z</dc:date>
    </item>
  </channel>
</rss>

