<?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 Datediff calculation error with days or weeks in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-calculation-error-with-days-or-weeks/m-p/2648719#M78032</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've direct queried a datatable from Microsoft Dynamics through the dataverse function and wanted to calculate the difference in days between two dates (with one date column being a calculated date column containing date values from a related table). I used the datediff function but I only get a result if I use months or years as the interval. When I use days (or even weeks) I receive the following error message: OLE DB or ODBC error: [Expression Error].&amp;nbsp; We couldn't fold the expression into the data source. Please try a simpler expression.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated. I can provide more detail if necessary.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jul 2022 21:02:06 GMT</pubDate>
    <dc:creator>pminnov</dc:creator>
    <dc:date>2022-07-19T21:02:06Z</dc:date>
    <item>
      <title>Datediff calculation error with days or weeks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-calculation-error-with-days-or-weeks/m-p/2648719#M78032</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've direct queried a datatable from Microsoft Dynamics through the dataverse function and wanted to calculate the difference in days between two dates (with one date column being a calculated date column containing date values from a related table). I used the datediff function but I only get a result if I use months or years as the interval. When I use days (or even weeks) I receive the following error message: OLE DB or ODBC error: [Expression Error].&amp;nbsp; We couldn't fold the expression into the data source. Please try a simpler expression.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated. I can provide more detail if necessary.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 21:02:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-calculation-error-with-days-or-weeks/m-p/2648719#M78032</guid>
      <dc:creator>pminnov</dc:creator>
      <dc:date>2022-07-19T21:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Datediff calculation error with days or weeks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-calculation-error-with-days-or-weeks/m-p/2649127#M78058</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="196437" data-lia-user-login="pminnov" class="lia-mention lia-mention-user"&gt;pminnov&lt;/a&gt; , try that inside a measure &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sumx(Table, datediff([Start date],[End date], day) )&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 03:45:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-calculation-error-with-days-or-weeks/m-p/2649127#M78058</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-07-20T03:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: Datediff calculation error with days or weeks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-calculation-error-with-days-or-weeks/m-p/2651084#M78150</link>
      <description>&lt;P&gt;Unfortunately your suggestion didn't work. If I try to use that formula in the form of a calculated column then SUMX isn't recognized as a function. The formula is accepted if I use it in a measure however when I try to show the results in a table visual I get the same error as before.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 17:11:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-calculation-error-with-days-or-weeks/m-p/2651084#M78150</guid>
      <dc:creator>pminnov</dc:creator>
      <dc:date>2022-07-20T17:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Datediff calculation error with days or weeks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-calculation-error-with-days-or-weeks/m-p/2658116#M78696</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="196437" data-lia-user-login="pminnov" class="lia-mention lia-mention-user"&gt;pminnov&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;According to the error message, by my research, I guess it's related to the DirectQuery mode, please try to use the import mode to check.&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ kalyj&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;helps,&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;then please consider&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 06:17:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-calculation-error-with-days-or-weeks/m-p/2658116#M78696</guid>
      <dc:creator>v-yanjiang-msft</dc:creator>
      <dc:date>2022-07-25T06:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: Datediff calculation error with days or weeks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-calculation-error-with-days-or-weeks/m-p/2659454#M78783</link>
      <description>&lt;P&gt;The expression does work however if months or years is used as the interval (just not weeks or days). The expression did work when I did a table merge then created a new column in the merged table and calculated the number of days between the two dates per row. I'm just confused as to why days or weeks was resulting in an error.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 14:22:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-calculation-error-with-days-or-weeks/m-p/2659454#M78783</guid>
      <dc:creator>pminnov</dc:creator>
      <dc:date>2022-07-25T14:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: Datediff calculation error with days or weeks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-calculation-error-with-days-or-weeks/m-p/2660623#M78878</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="196437" data-lia-user-login="pminnov" class="lia-mention lia-mention-user"&gt;pminnov&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Not sure why it only didn't work on days and weeks, but according to the error message, it's always related to the DirectQuery mode when there're complex data model or complex DAX. According to this&amp;nbsp;&lt;A href="https://blog.crossjoin.co.uk/2022/05/08/understanding-the-we-couldnt-fold-the-expression-to-the-data-source-error-in-power-bi/" target="_blank"&gt;blog&lt;/A&gt;, I guess it might be because when you use days and weeks in DAX,&amp;nbsp;&lt;SPAN&gt;DAX query generated by the visuals on your report has not be folded into queries against your data source.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Additionally, you can&amp;nbsp;also take a look at the discussions in the thread:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://community.powerbi.com/t5/Desktop/OLE-DB-or-ODBC-error-Expression-Error-We-couldn-t-fold-the/m-p/345720" target="_blank"&gt; OLE DB or ODBC error: [Expression.Error] We couldn... - Microsoft Power BI Community &lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ kalyj&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;helps,&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;then please consider&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 03:14:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-calculation-error-with-days-or-weeks/m-p/2660623#M78878</guid>
      <dc:creator>v-yanjiang-msft</dc:creator>
      <dc:date>2022-07-26T03:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Datediff calculation error with days or weeks</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-calculation-error-with-days-or-weeks/m-p/2678245#M80088</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="196437" data-lia-user-login="pminnov" class="lia-mention lia-mention-user"&gt;pminnov&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Is your problem solved?? If so, Would you mind accept the helpful replies as solutions? Then we are able to close the thread. More people who have the same requirement will find the solution quickly and benefit here. Thank you.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Community Support Team _ kalyj&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 10:19:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Datediff-calculation-error-with-days-or-weeks/m-p/2678245#M80088</guid>
      <dc:creator>v-yanjiang-msft</dc:creator>
      <dc:date>2022-08-03T10:19:56Z</dc:date>
    </item>
  </channel>
</rss>

