<?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 columns that outputs the difference in workdays shall only run if there are 2 dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-columns-that-outputs-the-difference-in-workdays-shall/m-p/2555079#M72504</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="395731" data-lia-user-login="teflonreis" class="lia-mention lia-mention-user"&gt;teflonreis&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Just delete the&amp;nbsp; &lt;STRONG&gt;, ""&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jun 2022 10:58:47 GMT</pubDate>
    <dc:creator>tamerj1</dc:creator>
    <dc:date>2022-06-02T10:58:47Z</dc:date>
    <item>
      <title>Calculated columns that outputs the difference in workdays shall only run if there are 2 dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-columns-that-outputs-the-difference-in-workdays-shall/m-p/2554861#M72474</link>
      <description>&lt;P&gt;Hello everyone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two columns with dates.&amp;nbsp;And have added a calculated date column that gives me the difference between the the dates in working days. So far so good.&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;CalculatedColumn&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;date1&lt;/TD&gt;&lt;TD&gt;date2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;5/23/2022&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;-2&lt;/TD&gt;&lt;TD&gt;5/23/2022&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;5/30/2022&lt;/TD&gt;&lt;TD&gt;6/1/2022&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However you probably noticed the problem. The calculated column magically makes up differences when there are no data or one date missing.&amp;nbsp;My two columns have lots of empy cells. In case of two empty cells, calculated columns gives me 0-0=0 days.&lt;/P&gt;&lt;P&gt;In case of only one date and one empty cell, if even gives me negatives number of days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I fail at adding a condition such that it only outputs the difference if there really are two date dates.&lt;/P&gt;&lt;P&gt;Since I want to compute the average number of working days in a Report, I get a wrong average (negative number of days).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Really am stuck and would appreciate some help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the condition I am thinking about. However never used variables before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;IF (AND(Table[date1]&amp;lt;&amp;gt;0, Table[date2]&amp;lt;&amp;gt;0), VAR CalculatedColumn, "Error or do nothing and dont go into average measure")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this is the CalculatedColumn formula that I currently use. I would make it a VAR Variable and add an IF statement. Again, never done that before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CalculatedColumn =
( DATEDIFF ( Table[date1], Table[date2], DAY ) )
    - INT ( DATEDIFF ( Table[date1], Table[date2], DAY ) / 7 ) * 2
    - IF (
        WEEKDAY ( Table[date2] ) &amp;lt; WEEKDAY ( Table[date1] ),
        2,
        IF (
            OR (
                WEEKDAY ( Table[date2] ) = 7,
                WEEKDAY ( Table[date1] ) = 1
            ),
            1,
            0
        )
    )&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 09:32:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-columns-that-outputs-the-difference-in-workdays-shall/m-p/2554861#M72474</guid>
      <dc:creator>teflonreis</dc:creator>
      <dc:date>2022-06-02T09:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated columns that outputs the difference in workdays shall only run if there are 2 dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-columns-that-outputs-the-difference-in-workdays-shall/m-p/2554953#M72487</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="395731" data-lia-user-login="teflonreis" class="lia-mention lia-mention-user"&gt;teflonreis&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Replace&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;AND(Table[date1]&amp;lt;&amp;gt;0, Table[date2]&amp;lt;&amp;gt;0)&lt;/LI-CODE&gt;&lt;P&gt;with&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;AND(Table[date1 &amp;gt; 0, Table[date2] &amp;gt; 0)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 02 Jun 2022 09:50:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-columns-that-outputs-the-difference-in-workdays-shall/m-p/2554953#M72487</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-06-02T09:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated columns that outputs the difference in workdays shall only run if there are 2 dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-columns-that-outputs-the-difference-in-workdays-shall/m-p/2555074#M72503</link>
      <description>&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Hate to be the guy that states the error codes:&lt;/P&gt;&lt;P&gt;Error "Expressions that yield variant data-type annot be used to define calculated columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I on the right path? Or was it a mistake to use variables in a calculated columns to begin with.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 10:58:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-columns-that-outputs-the-difference-in-workdays-shall/m-p/2555074#M72503</guid>
      <dc:creator>teflonreis</dc:creator>
      <dc:date>2022-06-02T10:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated columns that outputs the difference in workdays shall only run if there are 2 dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-columns-that-outputs-the-difference-in-workdays-shall/m-p/2555079#M72504</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="395731" data-lia-user-login="teflonreis" class="lia-mention lia-mention-user"&gt;teflonreis&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Just delete the&amp;nbsp; &lt;STRONG&gt;, ""&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 10:58:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-columns-that-outputs-the-difference-in-workdays-shall/m-p/2555079#M72504</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-06-02T10:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated columns that outputs the difference in workdays shall only run if there are 2 dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-columns-that-outputs-the-difference-in-workdays-shall/m-p/2555097#M72506</link>
      <description>&lt;P&gt;Oh that fixed it. Sorry for the stupid questions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many many thanks for the patience and help.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 11:04:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-columns-that-outputs-the-difference-in-workdays-shall/m-p/2555097#M72506</guid>
      <dc:creator>teflonreis</dc:creator>
      <dc:date>2022-06-02T11:04:43Z</dc:date>
    </item>
  </channel>
</rss>

