<?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: date difference with one simple condition in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/date-difference-with-one-simple-condition/m-p/3504361#M134428</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="612491" data-lia-user-login="mina97" class="lia-mention lia-mention-user"&gt;mina97&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can try the following methods&lt;/SPAN&gt;&lt;SPAN&gt;.&amp;nbsp;Create a new date table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Date = CALENDAR(MIN('Table'[sumitied date]),MAX('Table'[last action date]))&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure1 = 
Var _day1=CALCULATE(MAX('Table'[last action date]),FILTER(ALL('Table'),[status]="returned to client"))
Var _day2=CALCULATE(MAX('Table'[last action date]),FILTER(ALL('Table'),[status]="resubmited"))
Return
CALCULATE(COUNT('Date'[Date]),FILTER(ALL('Date'),[Date]&amp;gt;=_day1&amp;amp;&amp;amp;[Date]&amp;lt;=_day2&amp;amp;&amp;amp;[Weekday]&amp;lt;&amp;gt;5&amp;amp;&amp;amp;[Weekday]&amp;lt;&amp;gt;6))&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Measure2 = 
Var _day1=CALCULATE(MAX('Table'[last action date]),FILTER(ALL('Table'),[status]="returned to client"))
Var _day2=CALCULATE(MAX('Table'[last action date]),FILTER(ALL('Table'),[status]="resubmited"))
Return
DATEDIFF(_day1,_day2,DAY)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is this the result you expect?&lt;/SPAN&gt; &lt;SPAN&gt;Please see the attached document.&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;Community Support Team _Charlotte&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;STRONG&gt;helps, then please consider&amp;nbsp;&lt;EM&gt;Accept it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Oct 2023 10:44:21 GMT</pubDate>
    <dc:creator>v-zhangti</dc:creator>
    <dc:date>2023-10-30T10:44:21Z</dc:date>
    <item>
      <title>date difference with one simple condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/date-difference-with-one-simple-condition/m-p/3498226#M134051</link>
      <description>&lt;P&gt;hey i have the following data&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;order&lt;/TD&gt;&lt;TD&gt;sumitied date&lt;/TD&gt;&lt;TD&gt;last action date&lt;/TD&gt;&lt;TD&gt;status&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;216&lt;/TD&gt;&lt;TD&gt;12/10/2023&lt;/TD&gt;&lt;TD&gt;13/10/2023&lt;/TD&gt;&lt;TD&gt;sumitied&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;216&lt;/TD&gt;&lt;TD&gt;13/10/2023&lt;/TD&gt;&lt;TD&gt;13/10/2023&lt;/TD&gt;&lt;TD&gt;returned to client&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;216&lt;/TD&gt;&lt;TD&gt;20/10/2023&lt;/TD&gt;&lt;TD&gt;21/10/2023&lt;/TD&gt;&lt;TD&gt;resubmited&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;216&lt;/TD&gt;&lt;TD&gt;22/10/2023&lt;/TD&gt;&lt;TD&gt;30/10/2023&lt;/TD&gt;&lt;TD&gt;Approved&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;217&lt;/TD&gt;&lt;TD&gt;10/10/2023&lt;/TD&gt;&lt;TD&gt;10/10/2023&lt;/TD&gt;&lt;TD&gt;sumitied&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;217&lt;/TD&gt;&lt;TD&gt;10/10/2023&lt;/TD&gt;&lt;TD&gt;10/10/2023&lt;/TD&gt;&lt;TD&gt;Approved&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;i want to calculate the date difference for the order from the day the order got&lt;STRONG&gt; retuned to client&lt;/STRONG&gt;&amp;nbsp;to the day the order got &lt;STRONG&gt;resubmitted&lt;/STRONG&gt; only&amp;nbsp;&lt;BR /&gt;please help and thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 07:59:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/date-difference-with-one-simple-condition/m-p/3498226#M134051</guid>
      <dc:creator>mina97</dc:creator>
      <dc:date>2023-10-26T07:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: date difference with one simple condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/date-difference-with-one-simple-condition/m-p/3498242#M134052</link>
      <description>&lt;P&gt;&lt;STRONG&gt;1-exclude saturdays and fridays&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;2-including&amp;nbsp;saturdays and fridays&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 08:05:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/date-difference-with-one-simple-condition/m-p/3498242#M134052</guid>
      <dc:creator>mina97</dc:creator>
      <dc:date>2023-10-26T08:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: date difference with one simple condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/date-difference-with-one-simple-condition/m-p/3498350#M134058</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="612491" data-lia-user-login="mina97" class="lia-mention lia-mention-user"&gt;mina97&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;not sure if i fully get you, you may try to plot a table visual with order column and two measures like:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;WithoutFriSat = 
VAR _table = 
FILTER(
    data,
    data[order] = MAX(data[order])
)
VAR _day1 =
MAXX(
    FILTER(
        _table,
         data[status] = "returned to client"
    ),
    data[last action date]
)
VAR _day2 =
MAXX(
    FILTER(
        _table,
         data[status] = "resubmited"
    ),
    data[last action date]
)
VAR _days =
COUNTROWS(
    FILTER(
        CALENDAR(_day1, _day2),
        NOT WEEKDAY([date], 2) IN {5,6}
    )
)
RETURN 
IF( 
    ISBLANK(_day1)&amp;amp;&amp;amp;ISBLANK(_day2 ),
    BLANK(),
    _days
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;WithFriSat = 
VAR _table = 
FILTER(
    data,
    data[order] = MAX(data[order])
)
VAR _day1 =
MAXX(
    FILTER(
        _table,
         data[status] = "returned to client"
    ),
    data[last action date]
)
VAR _day2 =
MAXX(
    FILTER(
        _table,
         data[status] = "resubmited"
    ),
    data[last action date]
)
RETURN INT(_day2 - _day1) &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it worked like:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 08:41:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/date-difference-with-one-simple-condition/m-p/3498350#M134058</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-10-26T08:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: date difference with one simple condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/date-difference-with-one-simple-condition/m-p/3504361#M134428</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="612491" data-lia-user-login="mina97" class="lia-mention lia-mention-user"&gt;mina97&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can try the following methods&lt;/SPAN&gt;&lt;SPAN&gt;.&amp;nbsp;Create a new date table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Date = CALENDAR(MIN('Table'[sumitied date]),MAX('Table'[last action date]))&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure1 = 
Var _day1=CALCULATE(MAX('Table'[last action date]),FILTER(ALL('Table'),[status]="returned to client"))
Var _day2=CALCULATE(MAX('Table'[last action date]),FILTER(ALL('Table'),[status]="resubmited"))
Return
CALCULATE(COUNT('Date'[Date]),FILTER(ALL('Date'),[Date]&amp;gt;=_day1&amp;amp;&amp;amp;[Date]&amp;lt;=_day2&amp;amp;&amp;amp;[Weekday]&amp;lt;&amp;gt;5&amp;amp;&amp;amp;[Weekday]&amp;lt;&amp;gt;6))&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Measure2 = 
Var _day1=CALCULATE(MAX('Table'[last action date]),FILTER(ALL('Table'),[status]="returned to client"))
Var _day2=CALCULATE(MAX('Table'[last action date]),FILTER(ALL('Table'),[status]="resubmited"))
Return
DATEDIFF(_day1,_day2,DAY)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is this the result you expect?&lt;/SPAN&gt; &lt;SPAN&gt;Please see the attached document.&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;Community Support Team _Charlotte&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;STRONG&gt;helps, then please consider&amp;nbsp;&lt;EM&gt;Accept it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2023 10:44:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/date-difference-with-one-simple-condition/m-p/3504361#M134428</guid>
      <dc:creator>v-zhangti</dc:creator>
      <dc:date>2023-10-30T10:44:21Z</dc:date>
    </item>
  </channel>
</rss>

