<?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: DAX query for a Case statement in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/DAX-query-for-a-Case-statement/m-p/2453519#M35506</link>
    <description>&lt;P&gt;The DAX equivalent is SWITCH(TRUE(),...,...)&lt;/P&gt;</description>
    <pubDate>Wed, 13 Apr 2022 00:07:44 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2022-04-13T00:07:44Z</dc:date>
    <item>
      <title>DAX query for a Case statement</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/DAX-query-for-a-Case-statement/m-p/2450590#M35478</link>
      <description>&lt;P&gt;Hi , I am new in PowerBI, Can somebody please help me to create a DAX for the following Case statement,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Case when Year(SOLINE.[Deliv Date]) &amp;lt; Year(getdate()) then 'CurrentPeriod'&lt;BR /&gt;when Year(SOLINE.[Deliv Date]) = Year(getdate()) and month(SOLINE.[Deliv Date]) &amp;lt;= month(getdate()) then 'CurrentPeriod'&lt;BR /&gt;when Year(SOLINE.[Deliv Date]) = Year(getdate()) and month(SOLINE.[Deliv Date]) = month(getdate()) +1 then 'CurrentPeriod_1'&lt;BR /&gt;when Year(SOLINE.[Deliv Date]) = Year(getdate()) and month(SOLINE.[Deliv Date]) = month(getdate()) +2 then 'CurrentPeriod_2'&lt;BR /&gt;when Year(SOLINE.[Deliv Date]) = Year(getdate()) and month(SOLINE.[Deliv Date]) = month(getdate()) +3 then 'CurrentPeriod_3'&lt;BR /&gt;when Year(SOLINE.[Deliv Date]) = Year(getdate()) and month(SOLINE.[Deliv Date]) &amp;gt; month(getdate()) +3 then 'Forward' End SODeliveryPeriod&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 21:27:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/DAX-query-for-a-Case-statement/m-p/2450590#M35478</guid>
      <dc:creator>CSA1</dc:creator>
      <dc:date>2022-04-11T21:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: DAX query for a Case statement</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/DAX-query-for-a-Case-statement/m-p/2453519#M35506</link>
      <description>&lt;P&gt;The DAX equivalent is SWITCH(TRUE(),...,...)&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 00:07:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/DAX-query-for-a-Case-statement/m-p/2453519#M35506</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2022-04-13T00:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: DAX query for a Case statement</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/DAX-query-for-a-Case-statement/m-p/2456637#M35543</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/377759"&gt;@CSA1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Getdate() seems to be the function in SQL, we will use Now() to get current datetime in DAX.&lt;/P&gt;
&lt;P&gt;In addition to&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/user/viewprofilepage/user-id/100342" target="_self" aria-label="View Profile of lbendlin"&gt;lbendlin&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'s reply, you can try this code to create a calculated column.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Period =
SWITCH (
    TRUE (),
    YEAR ( SOLINE.[Deliv Date] ) &amp;lt; YEAR ( NOW () ), 'CurrentPeriod',
    YEAR ( SOLINE.[Deliv Date] ) = YEAR ( NOW () )
        &amp;amp;&amp;amp; MONTH ( SOLINE.[Deliv Date] ) &amp;lt;= MONTH ( NOW () ), 'CurrentPeriod',
    YEAR ( SOLINE.[Deliv Date] ) = YEAR ( NOW () )
        &amp;amp;&amp;amp; MONTH ( SOLINE.[Deliv Date] )
            = MONTH ( NOW () ) + 1, 'CurrentPeriod_1',
    YEAR ( SOLINE.[Deliv Date] ) = YEAR ( NOW () )
        &amp;amp;&amp;amp; MONTH ( SOLINE.[Deliv Date] )
            = MONTH ( NOW () ) + 2, 'CurrentPeriod_2',
    YEAR ( SOLINE.[Deliv Date] ) = YEAR ( NOW () )
        &amp;amp;&amp;amp; MONTH ( SOLINE.[Deliv Date] )
            = MONTH ( NOW () ) + 3, 'CurrentPeriod_3',
    YEAR ( SOLINE.[Deliv Date] ) = YEAR ( NOW () )
        &amp;amp;&amp;amp; MONTH ( SOLINE.[Deliv Date] )
            &amp;gt; MONTH ( NOW () ) + 3, 'Forward',
    "SODeliveryPeriod "
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&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>Thu, 14 Apr 2022 07:21:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/DAX-query-for-a-Case-statement/m-p/2456637#M35543</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-14T07:21:12Z</dc:date>
    </item>
  </channel>
</rss>

