<?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: SWITCH Function with multiple hits for criteria in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-Function-with-multiple-hits-for-criteria/m-p/3515268#M134939</link>
    <description>&lt;P&gt;Thank you so much! This worked perfectly... I just have one follow up question: let's say I want to classify the text using themes (example: if the string contains "cat" AND "dog", then return "domestic pet"); is this something I could tweak your above solution to inlcude by any chance? Or would I have to make a separate column for it.&lt;/P&gt;</description>
    <pubDate>Fri, 03 Nov 2023 21:12:26 GMT</pubDate>
    <dc:creator>cerbertttt</dc:creator>
    <dc:date>2023-11-03T21:12:26Z</dc:date>
    <item>
      <title>SWITCH Function with multiple hits for criteria</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-Function-with-multiple-hits-for-criteria/m-p/3514955#M134922</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I &lt;/SPAN&gt;recently started using Power BI a month ago. I'm currently trying to use SWITCH to sort through a column of text. The main problem that I am running into is that when a row has multiple words that satisfy the criteria for a case that I've coded for, the output column only contains the first case being satisfied, instead of all of the cases being satisfied.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the code I have so far:&lt;/P&gt;&lt;PRE&gt;SWITCH Hits Test =
SWITCH(
TRUE(),
CONTAINSSTRING('SWITCH Test'[Raw Data], "cat"), "cat",
CONTAINSSTRING('SWITCH Test'[Raw Data], "dog"), "dog",
CONTAINSSTRING('SWITCH Test'[Raw Data], "fox"), "fox",
"Not Target")   &lt;/PRE&gt;&lt;P&gt;And here's what my table looks like:&lt;/P&gt;&lt;DIV class=""&gt;&lt;BR /&gt;&lt;TABLE border="2"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Raw Data&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;SWITCH HitTest&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Ideal Result&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;dog cat&lt;/TD&gt;&lt;TD&gt;cat&lt;/TD&gt;&lt;TD&gt;cat, dog&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;dog dog&lt;/TD&gt;&lt;TD&gt;dog&lt;/TD&gt;&lt;TD&gt;dog&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;dog fox&lt;/TD&gt;&lt;TD&gt;dog&lt;/TD&gt;&lt;TD&gt;dog, fox&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;cat dog&lt;/TD&gt;&lt;TD&gt;cat&lt;/TD&gt;&lt;TD&gt;cat, dog&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;cat cat&lt;/TD&gt;&lt;TD&gt;cat&lt;/TD&gt;&lt;TD&gt;cat&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;cat fox&lt;/TD&gt;&lt;TD&gt;cat&lt;/TD&gt;&lt;TD&gt;cat, fox&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;test&lt;/TD&gt;&lt;TD&gt;Not Target&lt;/TD&gt;&lt;TD&gt;Not Target&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The solution that I've come up with is to make separate columns for each SWITCH case, but I was wondering if there was another workaround/potential function I could use before doing this as it seems time intensive for larger SWITCH functions. Any help would be greatly appreciated!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 17:41:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-Function-with-multiple-hits-for-criteria/m-p/3514955#M134922</guid>
      <dc:creator>cerbertttt</dc:creator>
      <dc:date>2023-11-03T17:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: SWITCH Function with multiple hits for criteria</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-Function-with-multiple-hits-for-criteria/m-p/3514991#M134923</link>
      <description>&lt;P&gt;This should work as a calculated column:&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;Ideal_Result = 
VAR _Concat =
    CONCATENATEX (
        FILTER (
            { "cat", "dog", "fox" },
            CONTAINSSTRING ( 'SWITCH Test'[Raw Data], [Value] )
        ),
        [Value],
        ", "
    )
VAR _Result =
    IF ( ISBLANK ( _Concat ), "Not Target", _Concat )
RETURN
    _Result&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 03 Nov 2023 17:45:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-Function-with-multiple-hits-for-criteria/m-p/3514991#M134923</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2023-11-03T17:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: SWITCH Function with multiple hits for criteria</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-Function-with-multiple-hits-for-criteria/m-p/3515268#M134939</link>
      <description>&lt;P&gt;Thank you so much! This worked perfectly... I just have one follow up question: let's say I want to classify the text using themes (example: if the string contains "cat" AND "dog", then return "domestic pet"); is this something I could tweak your above solution to inlcude by any chance? Or would I have to make a separate column for it.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 21:12:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-Function-with-multiple-hits-for-criteria/m-p/3515268#M134939</guid>
      <dc:creator>cerbertttt</dc:creator>
      <dc:date>2023-11-03T21:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: SWITCH Function with multiple hits for criteria</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-Function-with-multiple-hits-for-criteria/m-p/3515300#M134940</link>
      <description>&lt;P&gt;That sounds like pretty distinct logic but you can still use the &lt;FONT face="courier new,courier"&gt;FILTER ( ..., CONTAINSSTRING( ... ) )&lt;/FONT&gt; pattern to get a list of matches and then use set logic functions like &lt;FONT face="courier new,courier"&gt;INTERSECT&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;UNION&lt;/FONT&gt;, or&amp;nbsp;&lt;FONT face="courier new,courier"&gt;EXCEPT&lt;/FONT&gt;&amp;nbsp;to do the extra logic.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 21:53:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-Function-with-multiple-hits-for-criteria/m-p/3515300#M134940</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2023-11-03T21:53:41Z</dc:date>
    </item>
  </channel>
</rss>

