<?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: Calculating number of working days between TODAY and End Date (where TODAY is before/after End Date) in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2389856#M62103</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="365244" data-lia-user-login="annalisekerr" class="lia-mention lia-mention-user"&gt;annalisekerr&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;One way to that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Workdays between today and end date =
VAR CheckCondition = 'Iterations (2)'[Correct End Date] &amp;gt; 'Iterations (2)'[Todays Date]
VAR MinDate =
    IF (
        CheckCondition ,
        'Iterations (2)'[Todays Date],
        'Iterations (2)'[Correct End Date]
    )
VAR MaxDate =
    IF (
        CheckCondition ,
        'Iterations (2)'[Correct End Date],
        'Iterations (2)'[Todays Date]
    )
VAR Result =
    COUNTROWS (
        FILTER (
            ADDCOLUMNS (
                CALENDAR ( MinDate , MaxDate  ),
                "Day Of Week", WEEKDAY ( [Date], 2 )
            ),
            NOT ( [Day Of Week] IN { 6, 7 } )
        )
    )
RETURN
    IF ( CheckCondition , Result, - Result )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Mar 2022 09:00:33 GMT</pubDate>
    <dc:creator>tamerj1</dc:creator>
    <dc:date>2022-03-15T09:00:33Z</dc:date>
    <item>
      <title>Calculating number of working days between TODAY and End Date (where TODAY is before/after End Date)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2389159#M62060</link>
      <description>&lt;P&gt;Hi, I am trying to add a new colum to a table which calculates the number of days between a particular (end) date and today.&amp;nbsp; My problem is that some of the dates in the end date, is before todays date so I get an #ERROR message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideally i'd like&lt;/P&gt;&lt;P&gt;If the End date is &amp;gt; than todays date, return the number of days&lt;/P&gt;&lt;P&gt;If the End Date is &amp;lt; than todays date, return a -number of days&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to use the following&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please can anyone help??&amp;nbsp; I'm still very new to Power BI and DAX so still finding my feet&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":hugging_face:"&gt;🤗&lt;/span&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 11 Mar 2022 17:26:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2389159#M62060</guid>
      <dc:creator>annalisekerr</dc:creator>
      <dc:date>2022-03-11T17:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating number of working days between TODAY and End Date (where TODAY is before/after End Date)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2389248#M62068</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;Can you try:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Calc Col = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;venddate&lt;/SPAN&gt;&lt;SPAN&gt; = TableName&lt;/SPAN&gt;&lt;SPAN&gt;[End Date]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;vthisday&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;TODAY&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DATEDIFF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;venddate&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;vthisday&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;DAY&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;it will give pos &amp;amp; neg numbers.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 11 Mar 2022 18:51:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2389248#M62068</guid>
      <dc:creator>Whitewater100</dc:creator>
      <dc:date>2022-03-11T18:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating number of working days between TODAY and End Date (where TODAY is before/after End Date)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2389856#M62103</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="365244" data-lia-user-login="annalisekerr" class="lia-mention lia-mention-user"&gt;annalisekerr&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;One way to that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Workdays between today and end date =
VAR CheckCondition = 'Iterations (2)'[Correct End Date] &amp;gt; 'Iterations (2)'[Todays Date]
VAR MinDate =
    IF (
        CheckCondition ,
        'Iterations (2)'[Todays Date],
        'Iterations (2)'[Correct End Date]
    )
VAR MaxDate =
    IF (
        CheckCondition ,
        'Iterations (2)'[Correct End Date],
        'Iterations (2)'[Todays Date]
    )
VAR Result =
    COUNTROWS (
        FILTER (
            ADDCOLUMNS (
                CALENDAR ( MinDate , MaxDate  ),
                "Day Of Week", WEEKDAY ( [Date], 2 )
            ),
            NOT ( [Day Of Week] IN { 6, 7 } )
        )
    )
RETURN
    IF ( CheckCondition , Result, - Result )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 09:00:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2389856#M62103</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-15T09:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating number of working days between TODAY and End Date (where TODAY is before/after End Date)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2392091#M62253</link>
      <description>&lt;P&gt;Thank you , I will give this a try&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 10:42:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2392091#M62253</guid>
      <dc:creator>annalisekerr</dc:creator>
      <dc:date>2022-03-14T10:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating number of working days between TODAY and End Date (where TODAY is before/after End Date)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2392092#M62254</link>
      <description>&lt;P&gt;Thank you , I will give this a try&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 10:42:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2392092#M62254</guid>
      <dc:creator>annalisekerr</dc:creator>
      <dc:date>2022-03-14T10:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating number of working days between TODAY and End Date (where TODAY is before/after End Date)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2394560#M62416</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="365244" data-lia-user-login="annalisekerr" class="lia-mention lia-mention-user"&gt;annalisekerr&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a test&amp;nbsp;&lt;SPAN&gt;tamerj1 's code and I find there is something wrong in it. It will show error :&amp;nbsp;The start date in Calendar function can not be later than the end date.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;img /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Update Code:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Workdays between today and end date = 
VAR _CheckCondition = 'Iterations (2)'[Correct End Date] &amp;gt; 'Iterations (2)'[Todays Date]
VAR _MinDate =
    IF (
        _CheckCondition ,
        'Iterations (2)'[Todays Date],
        'Iterations (2)'[Correct End Date]
    )
VAR _MaxDate =
    IF (
        _CheckCondition ,
        'Iterations (2)'[Correct End Date],
        'Iterations (2)'[Todays Date]
    )
VAR _Result =
    COUNTROWS (
        FILTER (
            ADDCOLUMNS (
                CALENDAR ( _MinDate, _MaxDate ),
                "Day Of Week", WEEKDAY ( [Date], 2 )
            ),
            NOT ( [Day Of Week] IN { 6, 7 } )
        )
    )
RETURN
    IF (_CheckCondition,_Result,-_Result)&lt;/LI-CODE&gt;
&lt;P&gt;Result is as below.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&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>Tue, 15 Mar 2022 08:40:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2394560#M62416</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-15T08:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating number of working days between TODAY and End Date (where TODAY is before/after End Date)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2394613#M62420</link>
      <description>&lt;P&gt;Thank you for the correction. I've created the variables but missed to use them &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I will update my reply accordingly&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 08:58:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2394613#M62420</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-15T08:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating number of working days between TODAY and End Date (where TODAY is before/after End Date)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2397342#M62602</link>
      <description>&lt;P&gt;Perfect, yes that works brilliantly... thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 08:55:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2397342#M62602</guid>
      <dc:creator>annalisekerr</dc:creator>
      <dc:date>2022-03-16T08:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating number of working days between TODAY and End Date (where TODAY is before/after End Date)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2397443#M62606</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="365244" data-lia-user-login="annalisekerr" class="lia-mention lia-mention-user"&gt;annalisekerr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Well, that was my solution.&lt;/P&gt;&lt;P&gt;Thanks anyway.&lt;BR /&gt;Good luck and have a great day!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 09:27:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-number-of-working-days-between-TODAY-and-End-Date/m-p/2397443#M62606</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-16T09:27:59Z</dc:date>
    </item>
  </channel>
</rss>

