<?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: IF(DATEDIFF( .... in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-DATEDIFF/m-p/3705499#M144146</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="582496" data-lia-user-login="Dehlilah" class="lia-mention lia-mention-user"&gt;Dehlilah&lt;/a&gt;&amp;nbsp;So, a few possible improvements:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Expiration Category v2 =
  SWITCH(TRUE(),
    ( TODAY() - [Expiration Date] ) * 1. &amp;lt; 0, "Expired",
    ( TODAY() - [Expiration Date] ) * 1. &amp;lt;= 30, "Expires in 30 days",
    ( TODAY() - [Expiration Date] ) * 1. &amp;lt;= 60, "Expires in 60 days",
    "Expires in 180+ days"
  )&lt;/LI-CODE&gt;
&lt;P&gt;So, SWITCH(TRUE(), ...) is much cleaner than nested IF statements. Two, using simple math keeps the computation out of the formula engine which is faster. Dates are the number of days since December 30th, 1899 so you can just use subtraction to get the number of days.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on your data, you may want to reverse your logic. If the majority of the items are 180+ from expiring then you will want that condition first in your SWITCH statement for example. That way the majority of rows do not have to fail a bunch of other logical conditions before getting to the right one.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 17 Feb 2024 21:51:54 GMT</pubDate>
    <dc:creator>Greg_Deckler</dc:creator>
    <dc:date>2024-02-17T21:51:54Z</dc:date>
    <item>
      <title>IF(DATEDIFF( ....</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-DATEDIFF/m-p/3705482#M144145</link>
      <description>&lt;P&gt;I am really close to my desired outcome, but need to figure out a small change. I have a product that expires after two years. I have data on the order date, so I made a column called "Expiration Date" which is simply two years after the order date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created this coding:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Expiration Category v2 =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;IF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;DATEDIFF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;TODAY&lt;/SPAN&gt;&lt;SPAN&gt;(),&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Expiration Date]&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;DAY&lt;/SPAN&gt;&lt;SPAN&gt;)&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"Expired"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;IF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;DATEDIFF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;TODAY&lt;/SPAN&gt;&lt;SPAN&gt;(),&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Expiration Date]&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;DAY&lt;/SPAN&gt;&lt;SPAN&gt;)&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t;, &lt;/SPAN&gt;&lt;SPAN&gt;"Expires in 180+ days"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;))))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I want to know the amount of quantity that has expired, will expire soon (30 days or in 60 days) and 180+, but really I could change the last outcome 180+ to anything else or &amp;gt;61 days from expiration. Can someone help with this change? As I have it now the code doesn't capture total shippments, so something is off.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thank you!&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 17 Feb 2024 21:25:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-DATEDIFF/m-p/3705482#M144145</guid>
      <dc:creator>Dehlilah</dc:creator>
      <dc:date>2024-02-17T21:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: IF(DATEDIFF( ....</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-DATEDIFF/m-p/3705499#M144146</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="582496" data-lia-user-login="Dehlilah" class="lia-mention lia-mention-user"&gt;Dehlilah&lt;/a&gt;&amp;nbsp;So, a few possible improvements:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Expiration Category v2 =
  SWITCH(TRUE(),
    ( TODAY() - [Expiration Date] ) * 1. &amp;lt; 0, "Expired",
    ( TODAY() - [Expiration Date] ) * 1. &amp;lt;= 30, "Expires in 30 days",
    ( TODAY() - [Expiration Date] ) * 1. &amp;lt;= 60, "Expires in 60 days",
    "Expires in 180+ days"
  )&lt;/LI-CODE&gt;
&lt;P&gt;So, SWITCH(TRUE(), ...) is much cleaner than nested IF statements. Two, using simple math keeps the computation out of the formula engine which is faster. Dates are the number of days since December 30th, 1899 so you can just use subtraction to get the number of days.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on your data, you may want to reverse your logic. If the majority of the items are 180+ from expiring then you will want that condition first in your SWITCH statement for example. That way the majority of rows do not have to fail a bunch of other logical conditions before getting to the right one.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2024 21:51:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-DATEDIFF/m-p/3705499#M144146</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2024-02-17T21:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: IF(DATEDIFF( ....</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-DATEDIFF/m-p/3705518#M144153</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;, your solution works! Thank you for the code and the help!&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2024 22:33:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-DATEDIFF/m-p/3705518#M144153</guid>
      <dc:creator>Dehlilah</dc:creator>
      <dc:date>2024-02-17T22:33:38Z</dc:date>
    </item>
  </channel>
</rss>

