<?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: Average duration between two dates is not calculated in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2734251#M83829</link>
    <description>&lt;P&gt;My apologies for the late reply but now it works, thanks a lot!!!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Aug 2022 06:50:55 GMT</pubDate>
    <dc:creator>JoSwinnen</dc:creator>
    <dc:date>2022-08-30T06:50:55Z</dc:date>
    <item>
      <title>Average duration between two dates is not calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2722835#M83101</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with multiple lines for one student. For each year he is stuying at the university a line is created with his registrationdate of that year and his deregistrationdate of that year. I want to calculate how long students are studying on average.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried this one, based on&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Desktop/Calculate-Differance-Between-two-dates-grouping-by-another-field/m-p/2143410#M790663" target="_blank"&gt;https://community.powerbi.com/t5/Desktop/Calculate-Differance-Between-two-dates-grouping-by-another-field/m-p/2143410#M790663&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Study duration= &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; Startdate = &lt;/SPAN&gt;&lt;SPAN&gt;calculate&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;min&lt;/SPAN&gt;&lt;SPAN&gt;('vw_powerBI'[registrationdate]),&lt;/SPAN&gt;&lt;SPAN&gt;ALLEXCEPT&lt;/SPAN&gt;&lt;SPAN&gt;(vw_powerBI,vw_powerBI[studentnumber]))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; Enddate = &lt;/SPAN&gt;&lt;SPAN&gt;calculate&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;max&lt;/SPAN&gt;&lt;SPAN&gt;('vw_powerBI'[deregistrationdate]),&lt;/SPAN&gt;&lt;SPAN&gt;ALLEXCEPT&lt;/SPAN&gt;&lt;SPAN&gt;(vw_powerBI,vw_powerBI[studentnumber]))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&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;SPAN&gt;AVERAGEX&lt;/SPAN&gt;&lt;SPAN&gt;(vw_powerBI,&lt;/SPAN&gt;&lt;SPAN&gt;DATEDIFF&lt;/SPAN&gt;&lt;SPAN&gt;(Startdate, Enddate,DAY))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;But it is not giving the appropriate result.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Can anyone help?&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Jo&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 24 Aug 2022 09:49:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2722835#M83101</guid>
      <dc:creator>JoSwinnen</dc:creator>
      <dc:date>2022-08-24T09:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: Average duration between two dates is not calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2722933#M83108</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="391123" data-lia-user-login="JoSwinnen" class="lia-mention lia-mention-user"&gt;JoSwinnen&lt;/a&gt; , Try like &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Study duration=&lt;BR /&gt;VAR Startdate = calculate(min('vw_powerBI'[registrationdate]),ALLEXCEPT(vw_powerBI,vw_powerBI[studentnumber]))&lt;BR /&gt;VAR Enddate = calculate(max('vw_powerBI'[deregistrationdate]),ALLEXCEPT(vw_powerBI,vw_powerBI[studentnumber]))&lt;BR /&gt;RETURN&lt;BR /&gt;AVERAGEX(values(vw_powerBI,vw_powerBI[studentnumber]),calculate(DATEDIFF(Startdate, Enddate,DAY)))&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 10:11:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2722933#M83108</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-08-24T10:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Average duration between two dates is not calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2722974#M83115</link>
      <description>&lt;P&gt;Thanks for this. Now it gives for each student the correct duration but the average is not correct.&amp;nbsp;&lt;/P&gt;&lt;P&gt;And there is another difficulty that I'm realizing. I only want to calculate the study duration if this student has graduated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So there are different rows for one student and in the last year there will be 'yes' in the column 'graduated?' but in the previous rows there will be 'no'.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jo&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 10:23:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2722974#M83115</guid>
      <dc:creator>JoSwinnen</dc:creator>
      <dc:date>2022-08-24T10:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: Average duration between two dates is not calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2723028#M83120</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="391123" data-lia-user-login="JoSwinnen" class="lia-mention lia-mention-user"&gt;JoSwinnen&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Please try the following measure. Also I would really appreciate if you share more details about your visual and what columns are you slicing by in this visual.&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Study duration =
AVERAGEX (
    VALUES ( 'vw_powerBI'[studentnumber] ),
    CALCULATE (
        DATEDIFF (
            MIN ( 'vw_powerBI'[registrationdate] ),
            MAX ( 'vw_powerBI'[deregistrationdate] ),
            DAY
        )
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 10:45:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2723028#M83120</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-08-24T10:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: Average duration between two dates is not calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2723112#M83131</link>
      <description>&lt;P&gt;Thanks. This one gives a better result.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dataset looks like this:&lt;/P&gt;&lt;P&gt;Studentnumber&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;RegistrationDate&amp;nbsp; &amp;nbsp; &amp;nbsp; DeregistrationDate&amp;nbsp; &amp;nbsp; &amp;nbsp;Graduated?&lt;/P&gt;&lt;P&gt;00001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 15/09/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;30/06/2020&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; No&lt;/P&gt;&lt;P&gt;00001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 15/09/2020&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;30/06/2021&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; No&lt;/P&gt;&lt;P&gt;00001&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 15/09/2021&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;30/06/2022&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Yes&lt;/P&gt;&lt;P&gt;00002&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15/09/2020&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30/06/2021&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; No&lt;/P&gt;&lt;P&gt;00002&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15/09/2021&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30/06/2022&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; No&lt;/P&gt;&lt;P&gt;00003&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the formula above may only work when there is one row with a yes for that student. Students who tried but did not graduated (only no's) cant be included in the calculation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jo&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 11:25:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2723112#M83131</guid>
      <dc:creator>JoSwinnen</dc:creator>
      <dc:date>2022-08-24T11:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: Average duration between two dates is not calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2723232#M83139</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="391123" data-lia-user-login="JoSwinnen" class="lia-mention lia-mention-user"&gt;JoSwinnen&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Please try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Study duration =
VAR Graduated =
    CALCULATETABLE (
        VALUES ( 'vw_powerBI'[Graduated?] ),
        ALLEXCEPT ( 'vw_powerBI', 'vw_powerBI'[Studentnumber] )
    )
RETURN
    AVERAGEX (
        VALUES ( 'vw_powerBI'[studentnumber] ),
        CALCULATE (
            IF (
                "Yes" IN Graduated,
                DATEDIFF (
                    MIN ( 'vw_powerBI'[registrationdate] ),
                    MAX ( 'vw_powerBI'[deregistrationdate] ),
                    DAY
                )
            )
        )
    )
&lt;/LI-CODE&gt;
&lt;P&gt;Or&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Study duration =
VAR CurrentStudentTable =
    CALCULATETABLE (
        'vw_powerBI',
        ALLEXCEPT ( 'vw_powerBI', 'vw_powerBI'[Studentnumber] )
    )
VAR FiteredTable =
    FILTER ( CurrentStudentTable, 'vw_powerBI'[Graduated?] = "Yes" )
RETURN
    AVERAGEX (
        FiteredTable,
        DATEDIFF (
            MIN ( 'vw_powerBI'[registrationdate] ),
            MAX ( 'vw_powerBI'[deregistrationdate] ),
            DAY
        )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 12:19:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2723232#M83139</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-08-24T12:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: Average duration between two dates is not calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2724176#M83211</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried both ways, but it all gives the same result. The study duration for each student graduated or not...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jo&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 18:57:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2724176#M83211</guid>
      <dc:creator>JoSwinnen</dc:creator>
      <dc:date>2022-08-24T18:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: Average duration between two dates is not calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2724196#M83212</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="391123" data-lia-user-login="JoSwinnen" class="lia-mention lia-mention-user"&gt;JoSwinnen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Study duration =
VAR Graduated =
    CALCULATETABLE (
        VALUES ( 'vw_powerBI'[Graduated?] ),
        ALLEXCEPT ( 'vw_powerBI', 'vw_powerBI'[Studentnumber] )
    )
RETURN
    IF (
        "Yes" IN Graduated,
        AVERAGEX (
            VALUES ( 'vw_powerBI'[studentnumber] ),
            CALCULATE (
                DATEDIFF (
                    MIN ( 'vw_powerBI'[registrationdate] ),
                    MAX ( 'vw_powerBI'[deregistrationdate] ),
                    DAY
                )
            )
        )
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 24 Aug 2022 19:08:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2724196#M83212</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-08-24T19:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: Average duration between two dates is not calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2724220#M83216</link>
      <description>&lt;P&gt;Thank you for trying, but it still gives the same result.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 19:29:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2724220#M83216</guid>
      <dc:creator>JoSwinnen</dc:creator>
      <dc:date>2022-08-24T19:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: Average duration between two dates is not calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2724233#M83218</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="391123" data-lia-user-login="JoSwinnen" class="lia-mention lia-mention-user"&gt;JoSwinnen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to have a look at the data. Maybe we can connect tomorrow if you wish.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 19:36:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2724233#M83218</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-08-24T19:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: Average duration between two dates is not calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2724242#M83219</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="391123" data-lia-user-login="JoSwinnen" class="lia-mention lia-mention-user"&gt;JoSwinnen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would you please share a screenshot of the code you've been using&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 19:41:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2724242#M83219</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-08-24T19:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: Average duration between two dates is not calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2725346#M83280</link>
      <description>&lt;P&gt;Thank you for your help! I think I'm almost there, but I'm working on another project today. I will get back to it!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 08:18:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2725346#M83280</guid>
      <dc:creator>JoSwinnen</dc:creator>
      <dc:date>2022-08-25T08:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Average duration between two dates is not calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2725420#M83286</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;BR /&gt;actually when I saw your reply I had a 2nd look at the solution and the results.&amp;nbsp;&lt;BR /&gt;In your report you are slicing by&amp;nbsp;'vw_powerBI'[stamnummer] which means that the filter context contains the table of each student and there is no need to CALCULATETABLE - ALLEXCEPT.&amp;nbsp;Therefore, the&amp;nbsp;&lt;SPAN class=""&gt;VALUES&lt;SPAN class=""&gt;&amp;nbsp;(&lt;SPAN&gt;&amp;nbsp;'vw_powerBI'[Graduated?]&amp;nbsp;&lt;SPAN class=""&gt;) should contain all the "Yes" and "No" values for each "stamnummer". The limitation I set is: IF at least one "Yes" is available for the current student then do the calculation otherwise return blank.&amp;nbsp;I see no reason why this shouldn't work.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;However this condition need to be applied inside the SUMX as well in order to limit the total average (In the column total cell) to only the students who have "Yes" in their &lt;SPAN&gt;Graduate status.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Study duration =
IF (
    "Yes" IN VALUES ( 'vw_powerBI'[Graduated?] ),
    AVERAGEX (
        VALUES ( 'vw_powerBI'[stamnummer] ),
        IF (
            "Yes" IN CALCULATETABLE ( VALUES ( 'vw_powerBI'[Graduated?] ) ),
            DATEDIFF (
                CALCULATE ( MIN ( 'vw_powerBI'[registrationdate] ) ),
                CALCULATE ( MAX ( 'vw_powerBI'[deregistrationdate] ) ),
                DAY
            )
        )
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="391123" data-lia-user-login="JoSwinnen" class="lia-mention lia-mention-user"&gt;JoSwinnen&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 08:44:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2725420#M83286</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-08-25T08:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: Average duration between two dates is not calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2734251#M83829</link>
      <description>&lt;P&gt;My apologies for the late reply but now it works, thanks a lot!!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 06:50:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-duration-between-two-dates-is-not-calculated/m-p/2734251#M83829</guid>
      <dc:creator>JoSwinnen</dc:creator>
      <dc:date>2022-08-30T06:50:55Z</dc:date>
    </item>
  </channel>
</rss>

