<?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: Calculated column using switch in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Calculated-column-using-switch/m-p/3756234#M50325</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/703778"&gt;@wyller&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the way you want to use the SWITCH() function follows this logic:&lt;/P&gt;
&lt;P&gt;SWITCH(&lt;BR /&gt;TRUE,&lt;/P&gt;
&lt;P&gt;Condition1, OutputIfCondition1IsMet,&lt;/P&gt;
&lt;P&gt;Condition2, OutputIfCondition2IsMet,&lt;/P&gt;
&lt;P&gt;Condition3, OutputIfCondition3IsMet,&lt;/P&gt;
&lt;P&gt;...,&lt;/P&gt;
&lt;P&gt;OutputIfNoneOfTheAboveConditionIsMet&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is why I would say the second DAX code runs into a syntax error, since there is no condition after "In Review". I would also say the first DAX code might be semantically flawed since the output should result in&amp;nbsp;&lt;SPAN&gt;"Not Applicable" if&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;[CurrentStatus] = "Complete", which I am not sure, whether that is what you want.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Let me know if this helps &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;/Tom&lt;BR /&gt;&lt;A href="https://www.tackytech.blog/" target="_blank" rel="noopener"&gt;https://www.tackytech.blog/&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.instagram.com/tackytechtom/" target="_blank" rel="noopener"&gt;https://www.instagram.com/tackytechtom/&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Mar 2024 20:40:01 GMT</pubDate>
    <dc:creator>tackytechtom</dc:creator>
    <dc:date>2024-03-11T20:40:01Z</dc:date>
    <item>
      <title>Calculated column using switch</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Calculated-column-using-switch/m-p/3755854#M50320</link>
      <description>&lt;P&gt;I'm trying to create a calculated column using switch();&lt;/P&gt;&lt;P&gt;This 1st code worked fine. The 2nd throws an error. What am I doing wrong?&lt;/P&gt;&lt;P&gt;Aging =&lt;BR /&gt;VAR _daycount = DATEDIFF([Created], TODAY(), DAY)&lt;BR /&gt;RETURN&lt;BR /&gt;SWITCH(&lt;BR /&gt;TRUE(),&lt;BR /&gt;[CurrentStatus] = "Complete", "Not Applicable",&lt;BR /&gt;_daycount &amp;lt;= 30, "0-30 days old",&lt;BR /&gt;_daycount &amp;gt; 31 &amp;amp;&amp;amp; _daycount &amp;lt;=60, "31-60 days old",&lt;BR /&gt;_daycount &amp;gt; 61 &amp;amp;&amp;amp; _daycount &amp;lt;=90, "61-90 days old",&lt;BR /&gt;"Lifetime"&lt;BR /&gt;)&lt;BR /&gt;............&lt;/P&gt;&lt;P&gt;Aging2 =&lt;BR /&gt;VAR _daycount = DATEDIFF([Created], TODAY(), DAY)&lt;BR /&gt;RETURN&lt;BR /&gt;SWITCH(&lt;BR /&gt;TRUE(),&lt;BR /&gt;[CurrentStatus] = "In Process", "In Review", "Pending", "Submitted",&lt;BR /&gt;_daycount &amp;lt;= 30, "0-30 days old",&lt;BR /&gt;_daycount &amp;gt; 31 &amp;amp;&amp;amp; _daycount &amp;lt;=60, "31-60 days old",&lt;BR /&gt;_daycount &amp;gt; 61 &amp;amp;&amp;amp; _daycount &amp;lt;=90, "61-90 days old",&lt;BR /&gt;"Lifetime"&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The difference is in the 1st, there are only 2 conditions:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[CurrentStatus] = "Complete", "Not Applicable",&lt;/P&gt;&lt;P&gt;In the 2nd, there are 4:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[CurrentStatus] = "In Process", "In Review", "Pending", "Submitted",&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2024 16:25:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Calculated-column-using-switch/m-p/3755854#M50320</guid>
      <dc:creator>wyller</dc:creator>
      <dc:date>2024-03-11T16:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated column using switch</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Calculated-column-using-switch/m-p/3756234#M50325</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/703778"&gt;@wyller&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the way you want to use the SWITCH() function follows this logic:&lt;/P&gt;
&lt;P&gt;SWITCH(&lt;BR /&gt;TRUE,&lt;/P&gt;
&lt;P&gt;Condition1, OutputIfCondition1IsMet,&lt;/P&gt;
&lt;P&gt;Condition2, OutputIfCondition2IsMet,&lt;/P&gt;
&lt;P&gt;Condition3, OutputIfCondition3IsMet,&lt;/P&gt;
&lt;P&gt;...,&lt;/P&gt;
&lt;P&gt;OutputIfNoneOfTheAboveConditionIsMet&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is why I would say the second DAX code runs into a syntax error, since there is no condition after "In Review". I would also say the first DAX code might be semantically flawed since the output should result in&amp;nbsp;&lt;SPAN&gt;"Not Applicable" if&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;[CurrentStatus] = "Complete", which I am not sure, whether that is what you want.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Let me know if this helps &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;/Tom&lt;BR /&gt;&lt;A href="https://www.tackytech.blog/" target="_blank" rel="noopener"&gt;https://www.tackytech.blog/&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.instagram.com/tackytechtom/" target="_blank" rel="noopener"&gt;https://www.instagram.com/tackytechtom/&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2024 20:40:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Calculated-column-using-switch/m-p/3756234#M50325</guid>
      <dc:creator>tackytechtom</dc:creator>
      <dc:date>2024-03-11T20:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated column using switch</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Calculated-column-using-switch/m-p/3757220#M50335</link>
      <description>&lt;P&gt;Hi&amp;nbsp; &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/703778"&gt;@wyller&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/353745"&gt;@tackytechtom&lt;/a&gt;&amp;nbsp;&amp;nbsp;for sharing, I have something to add here as well.&lt;/P&gt;
&lt;P&gt;Is Dax's error message of the following form:&lt;/P&gt;
&lt;P&gt;Function 'SWITCH' does not support comparing values of type True/False with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vyangliumsft_0-1710228213975.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1058336i1642AA991A087E6F/image-size/large?v=v2&amp;amp;px=999" role="button" title="vyangliumsft_0-1710228213975.png" alt="vyangliumsft_0-1710228213975.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You can try using the following dax.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Aging2 = 
VAR _daycount = DATEDIFF([Created], TODAY(), DAY)
RETURN
SWITCH(
[CurrentStatus] IN{ "In Process", "In Review", "Pending", "Submitted"},
_daycount &amp;lt;= 30, "0-30 days old",
_daycount &amp;gt; 31 &amp;amp;&amp;amp; _daycount &amp;lt;=60, "31-60 days old",
_daycount &amp;gt; 61 &amp;amp;&amp;amp; _daycount &amp;lt;=90, "61-90 days old",
"Lifetime"
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vyangliumsft_0-1710228533746.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1058341iD14A64C9EADEF7BF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vyangliumsft_0-1710228533746.png" alt="vyangliumsft_0-1710228533746.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Liu Yang&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;Accept it as the solution&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2024 07:29:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Calculated-column-using-switch/m-p/3757220#M50335</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-03-12T07:29:02Z</dc:date>
    </item>
  </channel>
</rss>

