<?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: calculate average time between 2 database entries in a large database in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-average-time-between-2-database-entries-in-a-large/m-p/4145506#M164738</link>
    <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="393479" data-lia-user-login="StefanH74" class="lia-mention lia-mention-user"&gt;StefanH74&lt;/a&gt;, give this a try, and if you encounter any issues, let me know.&lt;/P&gt;&lt;P&gt;Here’s a modified version of your DAX, optimizing memory usage:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Cyclustijd = 
VAR order_ = vHardwareLog[orderNumber]
VAR created_ = vHardwareLog[created]
VAR created_previous_entry =
    CALCULATE(
        MAX(vHardwareLog[created]),
        REMOVEFILTERS(vHardwareLog),
        vHardwareLog[orderNumber] = order_ &amp;amp;&amp;amp; 
        vHardwareLog[created] &amp;lt; created_
    )
VAR cyclustijd_ = (created_ - created_previous_entry) * 86400
RETURN IF(cyclustijd_ &amp;lt;= 300, cyclustijd_)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P align="center"&gt;&lt;FONT face="verdana,geneva"&gt;&lt;FONT color="#99CC00"&gt;&lt;STRONG&gt;Did I answer your question?&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#99CC00"&gt;&lt;STRONG&gt;If so, please mark my post as the solution! &lt;span class="lia-unicode-emoji" title=":heavy_check_mark:"&gt;✔️&lt;/span&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="verdana,geneva"&gt;&lt;FONT color="#99CC00"&gt;&lt;STRONG&gt;Your Kudos are much appreciated!&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#99CC00"&gt;&lt;STRONG&gt;Proud to be a Solution Specialist!&lt;/STRONG&gt;&lt;/FONT&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Sep 2024 17:20:38 GMT</pubDate>
    <dc:creator>ahadkarimi</dc:creator>
    <dc:date>2024-09-11T17:20:38Z</dc:date>
    <item>
      <title>calculate average time between 2 database entries in a large database</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-average-time-between-2-database-entries-in-a-large/m-p/4144837#M164725</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a report where we can see the average cycle time of our products.&lt;/P&gt;&lt;P&gt;every time a cycle is completed on a machine (we have 30), a entry is made in the database.&lt;/P&gt;&lt;P&gt;so I need to compare the entry time with the previous entry (for that product) to get the time for that cycle, and then show in my report the average cycletime per product.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data looks like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;"Cyclustijd" is a calculated column to get the time (in seconds) between the entry and the previous one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Cyclustijd = 
VAR order_ = vHardwareLog[orderNumber]
VAR created_ = vHardwareLog[created]
VAR created_previous_entry =
CALCULATE(
    MAX(vHardwareLog[created]),
    FILTER(
        ALL(vHardwareLog),
        order_ = vHardwareLog[orderNumber] &amp;amp;&amp;amp;
        created_ &amp;gt; vHardwareLog[created]
    )
)
VAR cyclustijd_ = (created_ - created_previous_entry)*24*60*60

RETURN

IF(
    cyclustijd_ &amp;gt; 300,
    BLANK(),
    cyclustijd_
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and as you can see in the example above, it calculates just fine.&lt;/P&gt;&lt;P&gt;And in my report I can show the average cycle-time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that I can only run this with about a month of data (±270.000 database-entries)&lt;/P&gt;&lt;P&gt;anything bigger than that, and I get an error: "Not enough memory"&lt;/P&gt;&lt;P&gt;and I would really need it to run with at least a year's worth of data!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so if anyone knows a solution for this problem,&lt;/P&gt;&lt;P&gt;or can think of another way to get the result I need, I would greatly appreciate that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanx,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 12:07:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-average-time-between-2-database-entries-in-a-large/m-p/4144837#M164725</guid>
      <dc:creator>StefanH74</dc:creator>
      <dc:date>2024-09-11T12:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: calculate average time between 2 database entries in a large database</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-average-time-between-2-database-entries-in-a-large/m-p/4145506#M164738</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="393479" data-lia-user-login="StefanH74" class="lia-mention lia-mention-user"&gt;StefanH74&lt;/a&gt;, give this a try, and if you encounter any issues, let me know.&lt;/P&gt;&lt;P&gt;Here’s a modified version of your DAX, optimizing memory usage:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Cyclustijd = 
VAR order_ = vHardwareLog[orderNumber]
VAR created_ = vHardwareLog[created]
VAR created_previous_entry =
    CALCULATE(
        MAX(vHardwareLog[created]),
        REMOVEFILTERS(vHardwareLog),
        vHardwareLog[orderNumber] = order_ &amp;amp;&amp;amp; 
        vHardwareLog[created] &amp;lt; created_
    )
VAR cyclustijd_ = (created_ - created_previous_entry) * 86400
RETURN IF(cyclustijd_ &amp;lt;= 300, cyclustijd_)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P align="center"&gt;&lt;FONT face="verdana,geneva"&gt;&lt;FONT color="#99CC00"&gt;&lt;STRONG&gt;Did I answer your question?&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#99CC00"&gt;&lt;STRONG&gt;If so, please mark my post as the solution! &lt;span class="lia-unicode-emoji" title=":heavy_check_mark:"&gt;✔️&lt;/span&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="verdana,geneva"&gt;&lt;FONT color="#99CC00"&gt;&lt;STRONG&gt;Your Kudos are much appreciated!&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#99CC00"&gt;&lt;STRONG&gt;Proud to be a Solution Specialist!&lt;/STRONG&gt;&lt;/FONT&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 17:20:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-average-time-between-2-database-entries-in-a-large/m-p/4145506#M164738</guid>
      <dc:creator>ahadkarimi</dc:creator>
      <dc:date>2024-09-11T17:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: calculate average time between 2 database entries in a large database</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-average-time-between-2-database-entries-in-a-large/m-p/4145923#M164750</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="393479" data-lia-user-login="StefanH74" class="lia-mention lia-mention-user"&gt;StefanH74&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try changing the calculated column to a metric, which usually reduces memory consumption:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Cyclustijd = 
VAR order_ = SELECTEDVALUE(vHardwareLog[orderNumber])
VAR created_ = SELECTEDVALUE(vHardwareLog[created])
VAR created_previous_entry =
CALCULATE(
    MAX(vHardwareLog[created]),
    FILTER(
        ALL(vHardwareLog),
        vHardwareLog[orderNumber] = order_ &amp;amp;&amp;amp;
        vHardwareLog[created] &amp;lt; created_
    )
)
VAR cyclustijd_ = (created_ - created_previous_entry) * 24 * 60 * 60

RETURN
IF(
    cyclustijd_ &amp;gt; 300,
    BLANK(),
    cyclustijd_
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope it helps!&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_ Scott Chang&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps then please consider&amp;nbsp;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 02:03:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-average-time-between-2-database-entries-in-a-large/m-p/4145923#M164750</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-12T02:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: calculate average time between 2 database entries in a large database</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-average-time-between-2-database-entries-in-a-large/m-p/4146358#M164764</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="785426" data-lia-user-login="ahadkarimi" class="lia-mention lia-mention-user"&gt;ahadkarimi&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanx for the effort, unfortunately this makes no difference. cannot even do 2 months of data.&lt;/P&gt;&lt;P&gt;I think I will need a completely different approach to this problem, (even though I do not see how)&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 06:37:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-average-time-between-2-database-entries-in-a-large/m-p/4146358#M164764</guid>
      <dc:creator>StefanH74</dc:creator>
      <dc:date>2024-09-12T06:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: calculate average time between 2 database entries in a large database</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-average-time-between-2-database-entries-in-a-large/m-p/4146360#M164766</link>
      <description>&lt;P&gt;if only it was that simple....&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 06:38:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculate-average-time-between-2-database-entries-in-a-large/m-p/4146360#M164766</guid>
      <dc:creator>StefanH74</dc:creator>
      <dc:date>2024-09-12T06:38:33Z</dc:date>
    </item>
  </channel>
</rss>

