<?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 Switch / Case multiple results in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-Case-multiple-results/m-p/2064921#M46648</link>
    <description>&lt;P&gt;Hello all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm attempting to make an "error message" column in a table that can read multiple criteria and result the reasons there's an error message for the given project (rows in the table). I've found that Switch( True(),... ) only wants to find one criteria but I have overlapping cases where more than one case is true.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's generally what I've got so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Error Message = 
SWITCH(
TRUE(),
'Data'[Start_Date]=BLANK(),"Start Date is blank",
'Data'[Status]="Red","Status is Red",
//among several dozen other columns
"No Errors")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's my alternative since if/elif doesn't seem to be availabile in dax? Any ways to cycle back through the cases? Ultimately I'd like to find a way to concatenate the various error messages with commas into a single column (per row) in a table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas from the community? Thanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Sep 2021 17:32:33 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-09-08T17:32:33Z</dc:date>
    <item>
      <title>Switch / Case multiple results</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-Case-multiple-results/m-p/2064921#M46648</link>
      <description>&lt;P&gt;Hello all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm attempting to make an "error message" column in a table that can read multiple criteria and result the reasons there's an error message for the given project (rows in the table). I've found that Switch( True(),... ) only wants to find one criteria but I have overlapping cases where more than one case is true.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's generally what I've got so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Error Message = 
SWITCH(
TRUE(),
'Data'[Start_Date]=BLANK(),"Start Date is blank",
'Data'[Status]="Red","Status is Red",
//among several dozen other columns
"No Errors")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's my alternative since if/elif doesn't seem to be availabile in dax? Any ways to cycle back through the cases? Ultimately I'd like to find a way to concatenate the various error messages with commas into a single column (per row) in a table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas from the community? Thanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 17:32:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-Case-multiple-results/m-p/2064921#M46648</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-08T17:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: Switch / Case multiple results</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-Case-multiple-results/m-p/2064962#M46652</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;Well one way would be this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Error Message = 
SWITCH(
TRUE(),
'Data'[Start_Date]=BLANK() &amp;amp;&amp;amp; 'Data'[Status]="Red","Start Date is blank and red",
'Data'[Start_Date]=BLANK(),"Start Date is blank",
'Data'[Status]="Red","Status is Red",
//among several dozen other columns
"No Errors")&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 08 Sep 2021 18:20:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-Case-multiple-results/m-p/2064962#M46652</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-09-08T18:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Switch / Case multiple results</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-Case-multiple-results/m-p/2065083#M46660</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;Only problem is that if I hardcode every possibility, it will be very difficult to firstly add all the columns I need and secondly to update this as more situations require error messages. I have about 15 situations thus far and I'm still gathering requirements for this project. Any ideas on how to make this more dynamic and robust than just hardcoding every combination? Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 20:08:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-Case-multiple-results/m-p/2065083#M46660</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-08T20:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Switch / Case multiple results</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-Case-multiple-results/m-p/2065123#M46662</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;To form a reasonable approach, I would need to better understand your requirements. Can you provide some sample data and then the current rules that you have collected? I could formulate an approach then that would be specific. That said, there are constructs for emulating for loops in DAX.&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/For-Loop/m-p/637531#M319" target="_blank"&gt;For Loop - Microsoft Power BI Community&lt;/A&gt;. I could envision an approach where you have your rules table and for each rule you would perform a specific check and add the result of that check as a column using ADDCOLUMNS. So, for example, take your SWITCH statement as the basis for your ADDCOLUMNS value return but modify it so that it functions based upon rule ID. Something like:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Errors Message = 
  VAR __Table = 
    ADDCOLUMNS(
      'RulesTable',
      "Error",
        SWITCH(TRUE(),
          [RuleID] = 1, IF('Data'[Start_Date]=BLANK(),"Start Date is blank",BLANK()),
          [RuleID] = 2, IF('Data'[Status]="Red","Status is Red",BLANK())
        )
    )
RETURN
  CONCATENATEX(__Table,[Error],,", ")&lt;/LI-CODE&gt;
&lt;P&gt;This would return a single text string of all of the matching error conditions.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 20:40:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-Case-multiple-results/m-p/2065123#M46662</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-09-08T20:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Switch / Case multiple results</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-Case-multiple-results/m-p/2069512#M46811</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;Thanks for sharing that for loop resource. The columns I'm looking at are mainly in the same table and are simple logical things I can check with an IF statement. Can't share details but it's just a bunch of projects with many measurements stored in different columns.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where do I instantiate the [RuleID] columns? Should I create a RulesTable separate from the one constructed in the variable table that we're looping through? Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 10 Sep 2021 17:15:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-Case-multiple-results/m-p/2069512#M46811</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-10T17:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Switch / Case multiple results</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-Case-multiple-results/m-p/2069608#M46814</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;I don't need your data, I just need data that simulates your data.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Sep 2021 18:13:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-Case-multiple-results/m-p/2069608#M46814</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-09-10T18:13:10Z</dc:date>
    </item>
  </channel>
</rss>

