<?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: Datadiff returns wrong value in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datadiff-returns-wrong-value/m-p/2868766#M92504</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you change the aggregation from SUM to MAX or MIN you will get correct results at the table visual row level but wrong at the total level.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have two options.&amp;nbsp;&lt;BR /&gt;first option is to create a measure based on the Date Var column that you have created&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Difference (days) =
SUMX (
    SUMMARIZE ( 'Table', 'Table'[Invoice Date], 'Table'[Service/ Tax Date] ),
    CALCULATE ( MAX ( 'Table'[Date Var] ) )
)&lt;/LI-CODE&gt;
&lt;P&gt;or directly using the following measure&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Difference (days) =
SUMX (
    SUMMARIZE ( 'Table', 'Table'[Invoice Date], 'Table'[Service/ Tax Date] ),
    DATEDIFF ( 'Table'[Service/ Tax Date], 'Table'[Invoice Date], DAY )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Oct 2022 17:04:34 GMT</pubDate>
    <dc:creator>tamerj1</dc:creator>
    <dc:date>2022-10-27T17:04:34Z</dc:date>
    <item>
      <title>Datadiff returns wrong value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datadiff-returns-wrong-value/m-p/2868714#M92498</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am calculating a simply date difference using Datediff function. But the value I got is wrong. I check the data types of the two date column are date. I still can not find the reason. Please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;Branko&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2022 16:25:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datadiff-returns-wrong-value/m-p/2868714#M92498</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-27T16:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: Datadiff returns wrong value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datadiff-returns-wrong-value/m-p/2868743#M92501</link>
      <description>&lt;P&gt;If in doubt... please consult&amp;nbsp;&lt;A href="https://dax.guide/datediff/" target="_blank"&gt;DATEDIFF – DAX Guide&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2022 16:54:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datadiff-returns-wrong-value/m-p/2868743#M92501</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-10-27T16:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: Datadiff returns wrong value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datadiff-returns-wrong-value/m-p/2868766#M92504</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you change the aggregation from SUM to MAX or MIN you will get correct results at the table visual row level but wrong at the total level.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have two options.&amp;nbsp;&lt;BR /&gt;first option is to create a measure based on the Date Var column that you have created&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Difference (days) =
SUMX (
    SUMMARIZE ( 'Table', 'Table'[Invoice Date], 'Table'[Service/ Tax Date] ),
    CALCULATE ( MAX ( 'Table'[Date Var] ) )
)&lt;/LI-CODE&gt;
&lt;P&gt;or directly using the following measure&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Difference (days) =
SUMX (
    SUMMARIZE ( 'Table', 'Table'[Invoice Date], 'Table'[Service/ Tax Date] ),
    DATEDIFF ( 'Table'[Service/ Tax Date], 'Table'[Invoice Date], DAY )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2022 17:04:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datadiff-returns-wrong-value/m-p/2868766#M92504</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-10-27T17:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Datadiff returns wrong value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datadiff-returns-wrong-value/m-p/2868801#M92508</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your solution!!!!&amp;nbsp; But could you tell me the reason, why I can't get right outcoming by simply using DateDiff?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2022 17:23:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datadiff-returns-wrong-value/m-p/2868801#M92508</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-27T17:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: Datadiff returns wrong value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datadiff-returns-wrong-value/m-p/2868826#M92511</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem is not with DATEDIFF. You are creating a calculated column and you have duplicate dates. It depends on your business logic. Actually, the first result you got is arguably correct. If you divide the number of days over how many times the&amp;nbsp;'Table'[Invoice Date] ; 'Table'[Service/ Tax Date] combination is dupicated in your data, you'll get the same result on my solution. However, it can be argued the first result is the correct one as it aggregates the days for each record. It is up to your business requirement and logic to determine which result is required.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2022 17:37:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datadiff-returns-wrong-value/m-p/2868826#M92511</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-10-27T17:37:45Z</dc:date>
    </item>
  </channel>
</rss>

