<?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: Total average of datediff in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Total-average-of-datediff/m-p/3447352#M131213</link>
    <description>&lt;P&gt;Thank you!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the code just like you wrote it, which didn't give the correct values but when i tried using datediff instead of subtracting the dates, it does work. It is very possible that I am doing something else wrong when I am subtracting the values but I am just glad it works now!&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Sep 2023 08:26:01 GMT</pubDate>
    <dc:creator>Jodallen123</dc:creator>
    <dc:date>2023-09-26T08:26:01Z</dc:date>
    <item>
      <title>Total average of datediff</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Total-average-of-datediff/m-p/3447133#M131188</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a measure that calculates average handling time per project. My data looks something like this, it's a table with logs of status changes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My current measure looks like this, when i drag it to a table with ordernumber, it gives the correct number of days per ordernumber, but the total at the bottom shows the total difference between the min and the max date, and not the total average per ordernumber. I know that the current measure won't show the average since i haven't included any averages in the measure, i have however tried to alter the measure in a bunch of ways, but the result is still the same.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;PL handling time =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;minbookedmeeting&lt;/SPAN&gt;&lt;SPAN&gt; =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;MIN&lt;/SPAN&gt;&lt;SPAN&gt; ( &lt;/SPAN&gt;&lt;SPAN&gt;'logs'&lt;/SPAN&gt;&lt;SPAN&gt;[Created_date]&lt;/SPAN&gt;&lt;SPAN&gt; ),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;'logs'&lt;/SPAN&gt;&lt;SPAN&gt;[status_changed_to]&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;"B"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; || &lt;/SPAN&gt;&lt;SPAN&gt;logs'&lt;/SPAN&gt;&lt;SPAN&gt;[status_changed_to]&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;"C"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SP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t;&lt;SPAN&gt;DATEDIFF&lt;/SPAN&gt;&lt;SPAN&gt;( &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;minbookedmeeting&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;maxcustomerdone&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;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;datedifference&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would very much appreciate some input on how I can change the measure to show what I want, thanks in advance!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2023 06:20:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Total-average-of-datediff/m-p/3447133#M131188</guid>
      <dc:creator>Jodallen123</dc:creator>
      <dc:date>2023-09-26T06:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: Total average of datediff</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Total-average-of-datediff/m-p/3447280#M131207</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="588595" data-lia-user-login="Jodallen123" class="lia-mention lia-mention-user"&gt;Jodallen123&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;PL handling time =
AVERAGEX (
    VALUES ( 'logs'[Ordernumber] ),
    VAR minbookedmeeting =
        CALCULATE (
            MIN ( 'logs'[Created_date] ),
            'logs'[status_changed_to] = "B"
                || 'logs'[status_changed_to] = "C"
        )
    VAR maxcustomerdone =
        CALCULATE (
            MAX ( 'logs'[Created_date] ),
            'logs'[status_changed_to] = "D"
                || 'logs'[status_changed_to] = "E"
        )
    VAR datedifference = maxcustomerdone - minbookedmeeting
    RETURN
        datedifference
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's essentially the same code as you had, but wrapped in &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;AVERAGEX ( VALUES (... ), ... )&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;AVERAGEX (
    VALUES ( 'logs'[Ordernumber] ),
    &amp;lt;your original code&amp;gt;
)&lt;/LI-CODE&gt;
&lt;P&gt;This will compute the datedifference for each Ordernumber, then return the arithmetic mean of these values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For simplicity, I also suggest subtracting the dates rather than using DATEDIFF (they are both valid though).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this work for you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2023 07:38:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Total-average-of-datediff/m-p/3447280#M131207</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-09-26T07:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: Total average of datediff</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Total-average-of-datediff/m-p/3447352#M131213</link>
      <description>&lt;P&gt;Thank you!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the code just like you wrote it, which didn't give the correct values but when i tried using datediff instead of subtracting the dates, it does work. It is very possible that I am doing something else wrong when I am subtracting the values but I am just glad it works now!&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2023 08:26:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Total-average-of-datediff/m-p/3447352#M131213</guid>
      <dc:creator>Jodallen123</dc:creator>
      <dc:date>2023-09-26T08:26:01Z</dc:date>
    </item>
  </channel>
</rss>

