<?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 Calculation of 4 weeks Rolling average based on condition in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3323920#M124459</link>
    <description>&lt;P&gt;Hi everyone ,&lt;BR /&gt;I'm trying to create a measure for a rolling 4-week average. Here's how the calculation should be done:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;If the technician's name is present in the previous 4 weeks, the calculation is as follows:&lt;BR /&gt;(R_S_E + C_S_E + R_Z_Act Hrs * Previous Weeks Avg + C_Z_Act Hrs * Previous Weeks Avg) / Hours on Task.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;If the technician is not present in any of the weeks in the previous 4 weeks, we will follow a general formula:&lt;BR /&gt;(R_S_E + C_S_E + R_Z_Act Hrs + C_Z_Act Hrs) / Hours on Task.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;All of these calculations should be included in a single measure. I have also attached a sample Pbix file and a snapshot of the desired result that I would like to see.&lt;/P&gt;&lt;P&gt;&lt;A href="https://1drv.ms/u/s!AhrNHz36tk5VhVfDkNm0w7vQbvT0?e=UUHPut" target="_blank" rel="noopener"&gt;Sample Data Zero Dollar Work.pbix&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="403972" data-lia-user-login="v-jianboli-msft" class="lia-mention lia-mention-user"&gt;v-jianboli-msft&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="240987" data-lia-user-login="johnt75" class="lia-mention lia-mention-user"&gt;johnt75&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;&amp;nbsp;, &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="291628" data-lia-user-login="Jihwan_Kim" class="lia-mention lia-mention-user"&gt;Jihwan_Kim&lt;/a&gt;&amp;nbsp;&amp;nbsp; , @&lt;A href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/433015" target="_self"&gt;v-yueyunzh-msft&lt;/A&gt;,&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;,&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="433015" data-lia-user-login="v-yueyunzh-msft" class="lia-mention lia-mention-user"&gt;v-yueyunzh-msft&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thanx in advance please help me on this one, your help is much needed&amp;nbsp;&lt;BR /&gt;Thanks and regards&amp;nbsp;&lt;BR /&gt;Learner27&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jul 2023 20:37:49 GMT</pubDate>
    <dc:creator>Learner27</dc:creator>
    <dc:date>2023-07-10T20:37:49Z</dc:date>
    <item>
      <title>Calculation of 4 weeks Rolling average based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3323920#M124459</link>
      <description>&lt;P&gt;Hi everyone ,&lt;BR /&gt;I'm trying to create a measure for a rolling 4-week average. Here's how the calculation should be done:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;If the technician's name is present in the previous 4 weeks, the calculation is as follows:&lt;BR /&gt;(R_S_E + C_S_E + R_Z_Act Hrs * Previous Weeks Avg + C_Z_Act Hrs * Previous Weeks Avg) / Hours on Task.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;If the technician is not present in any of the weeks in the previous 4 weeks, we will follow a general formula:&lt;BR /&gt;(R_S_E + C_S_E + R_Z_Act Hrs + C_Z_Act Hrs) / Hours on Task.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;All of these calculations should be included in a single measure. I have also attached a sample Pbix file and a snapshot of the desired result that I would like to see.&lt;/P&gt;&lt;P&gt;&lt;A href="https://1drv.ms/u/s!AhrNHz36tk5VhVfDkNm0w7vQbvT0?e=UUHPut" target="_blank" rel="noopener"&gt;Sample Data Zero Dollar Work.pbix&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="403972" data-lia-user-login="v-jianboli-msft" class="lia-mention lia-mention-user"&gt;v-jianboli-msft&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="240987" data-lia-user-login="johnt75" class="lia-mention lia-mention-user"&gt;johnt75&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;&amp;nbsp;, &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="291628" data-lia-user-login="Jihwan_Kim" class="lia-mention lia-mention-user"&gt;Jihwan_Kim&lt;/a&gt;&amp;nbsp;&amp;nbsp; , @&lt;A href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/433015" target="_self"&gt;v-yueyunzh-msft&lt;/A&gt;,&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;,&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="433015" data-lia-user-login="v-yueyunzh-msft" class="lia-mention lia-mention-user"&gt;v-yueyunzh-msft&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thanx in advance please help me on this one, your help is much needed&amp;nbsp;&lt;BR /&gt;Thanks and regards&amp;nbsp;&lt;BR /&gt;Learner27&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 20:37:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3323920#M124459</guid>
      <dc:creator>Learner27</dc:creator>
      <dc:date>2023-07-10T20:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation of 4 weeks Rolling average based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3324041#M124463</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="583663" data-lia-user-login="Learner27" class="lia-mention lia-mention-user"&gt;Learner27&lt;/a&gt;&amp;nbsp;See if this helps:&lt;/P&gt;
&lt;P&gt;&lt;div data-video-id="https://youtu.be/TkrHfRFjpSc" data-video-remote-vid="https://youtu.be/TkrHfRFjpSc" class="lia-video-container lia-media-is-center lia-media-size-medium"&gt;&lt;iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FTkrHfRFjpSc%3Ffeature%3Doembed&amp;amp;display_name=YouTube&amp;amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DTkrHfRFjpSc&amp;amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FTkrHfRFjpSc%2Fhqdefault.jpg&amp;amp;type=text%2Fhtml&amp;amp;schema=youtube" allowfullscreen="" style="max-width: 100%"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 23:25:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3324041#M124463</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2023-07-10T23:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation of 4 weeks Rolling average based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3324662#M124485</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="583663" data-lia-user-login="Learner27" class="lia-mention lia-mention-user"&gt;Learner27&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you provide a worked example of the calculation, for both cases (technician present and technician not present in prior 4 weeks)?&lt;/P&gt;
&lt;P&gt;It's not clear what Previous Weeks Avg refers to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 08:04:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3324662#M124485</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-07-11T08:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation of 4 weeks Rolling average based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3324836#M124492</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thank you for Quick response,&lt;BR /&gt;I have shared you the excel file in your Inbox please let me know if&amp;nbsp; any further information is required.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 09:22:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3324836#M124492</guid>
      <dc:creator>Learner27</dc:creator>
      <dc:date>2023-07-11T09:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation of 4 weeks Rolling average based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3326742#M124577</link>
      <description>&lt;P&gt;Hi again&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="583663" data-lia-user-login="Learner27" class="lia-mention lia-mention-user"&gt;Learner27&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have had a look at the PBIX/Excel file (got a bit busy since yesterday). Thanks for providing those &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have suggested below some DAX code for the Zero Rate Dollar Work measure that should be structurally what you need, but is missing the expression for "Previous Weeks Avg". Could you try to populate that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edited PBIX is attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notes on the measure:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I have assumed that the measure should only be evaluated for a single Week and AssignedTechnician. This is the reason for the HASONEVALUE tests at the start.&lt;/LI&gt;
&lt;LI&gt;If the above assumption is incorrect, we would need some logic for aggregating across Technicians and weeks.&lt;/LI&gt;
&lt;LI&gt;The &lt;STRONG&gt;ExistsInPreviousFourWeeks&lt;/STRONG&gt; variable returns True if the current technician appeared in the previous 4 weeks in ST_PFP_Report table (ignoring any other filters that might be present).&lt;/LI&gt;
&lt;LI&gt;The &lt;STRONG&gt;PreviousWeeksAvg&lt;/STRONG&gt; variable is set to 1 (calculated over previous 4 weeks) as I didn't follow how it should be calculated sorry. You can replace this with the correct expression.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Zero Rate Dollar Work = 
IF (
    HASONEVALUE ( 'Calendar'[start date] ) -- single week filtered
        &amp;amp;&amp;amp; HASONEVALUE ( ST_PFP_Report[AssignedTechnicians] ), -- single Technician filtered
        -- Get the previous 4 weeks (before the single filtered week)
    VAR PreviousFourWeeks =
        WINDOW ( -1, REL, -4, REL, ALL ( 'Calendar'[start date] ) )

    -- Determine if the current Technician
    -- appeared in the previous 4 weeks
    VAR ExistsInPreviousFourWeeks =
        CALCULATE (
            NOT ISEMPTY ( ST_PFP_Report ),
            ALL ( 'Calendar' ), -- clear 'Calendar' filters (technically not needed as 'Calendar' is in expanded ST_PFP_Report table)
            PreviousFourWeeks -- filter on Previous 4 weeks
        )
    VAR Result =
        IF (
            ExistsInPreviousFourWeeks, -- True/False
            -- Option 1: Calculation based on previous 4 weeks
            VAR PreviousWeeksAvg =
                CALCULATE (
                    1, -- *** replace this with correct expression ***
                    ALL ( 'Calendar' ), -- clear 'Calendar' filters (technically not needed as 'Calendar' is in expanded ST_PFP_Report table)
                    PreviousFourWeeks -- filter on Previous 4 weeks
                )
            RETURN
                DIVIDE (
                    [R_S_E] + [C_S_E] + [R_Z_ Act Hrs] * PreviousWeeksAvg
                    + [C_Z_Act Hrs] * PreviousWeeksAvg,
                    [Hours On Task]
                ),
            -- Option 2: General formula
            DIVIDE (
                [R_S_E] + [C_S_E] + [R_Z_ Act Hrs] + [C_Z_Act Hrs],
                [Hours On Task]
            )
        )
    RETURN
        Result
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There could well be issues as I don't have a full understanding of the background to the calculation, so please treat this as guidance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Owen&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2023 07:24:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3326742#M124577</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-07-12T07:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation of 4 weeks Rolling average based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3327066#M124587</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for the measure &amp;nbsp;but there is still some missing part in the measure.&lt;BR /&gt;The part where we use previous weeks average, it is upto calculation multiplying with previous 4 weeks average and in this 4 weeks average it consists of below calculation :&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[R_S_E]&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;SPAN&gt;[C_S_E]&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;SPAN&gt;[R_Z_ Act Hrs]&lt;/SPAN&gt;&lt;SPAN&gt; * &lt;/SPAN&gt;&lt;SPAN&gt;PreviousWeeksAvg&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; + &lt;/SPAN&gt;&lt;SPAN&gt;[C_Z_Act Hrs]&lt;/SPAN&gt;&lt;SPAN&gt; * &lt;/SPAN&gt;&lt;SPAN&gt;PreviousWeeksAvg&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;[Hours On Task]&lt;BR /&gt;Basically it is like rolling 4 weeks average for the next week for each week&amp;nbsp;&lt;BR /&gt;I tried to figure out rolling 4 week average&amp;nbsp; for the previous week but it is breaking our measure&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 12 Jul 2023 09:56:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3327066#M124587</guid>
      <dc:creator>Learner27</dc:creator>
      <dc:date>2023-07-12T09:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation of 4 weeks Rolling average based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3327253#M124606</link>
      <description>&lt;P&gt;Thanks for the feedback - yes, this is the part of the measure where I confess I didn't fully understand the requirements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think it might be easiest to take an example from the Power BI dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If we look at Andrew Dusett as at 2022 week 10, could you show me would be the correct calculation for "previous 4 weeks average"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have created a page to show his values by week (attached)&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2023 11:58:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3327253#M124606</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-07-12T11:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation of 4 weeks Rolling average based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3327397#M124617</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;"Thank you so much for putting in the effort to help me.&lt;BR /&gt;I truly appreciate it. I am new to window functions in Power BI, and thanks to you, I have learned about them. Once again, a big thank you to you."&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;"The four-week average should be calculated as follows:"&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;calculation would be &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1st week = (R_S_E(3511.96)+C_S_E(0.00)+R_Z_act hrs(9.02)+ C_Z_Act Hrs(0.00)) / Hours on task(74.08)=47.53&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2nd week = (R_S_E(299.8)+C_S_E(0.00)+R_Z_act hrs(17.51)+ C_Z_Act Hrs(0.00)) / Hours on task(74.97)=40.23&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3rd week = (R_S_E(3579.41)+C_S_E(0.00)+R_Z_act hrs(0.00)+ C_Z_Act Hrs(0.00)) / Hours on task(108.36)=33.03&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;4th week = (R_S_E(242.89)+C_S_E(0.00)+R_Z_act hrs(0.00)+ C_Z_Act Hrs(0.00)) / Hours on task(32.75)=7.42&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;_______________&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;5th week Average Wolud be previous 4 weeks average sum =(47.53+40.23+33.03+7.42 )/4 i.e = 32.05&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;6th week = week2+week3+week4+week5 =(40.23+33.03+7.42+32.05)/4 = 28.18&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;like this process should continue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if we are in 2023 week 1 would be as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;= 2022 week49 +2022 week50+2022 week 51+2022 week 52&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2023 13:00:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3327397#M124617</guid>
      <dc:creator>Learner27</dc:creator>
      <dc:date>2023-07-12T13:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation of 4 weeks Rolling average based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3331285#M124836</link>
      <description>&lt;P&gt;Thanks for the further detail&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="583663" data-lia-user-login="Learner27" class="lia-mention lia-mention-user"&gt;Learner27&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have attached my current working PBIX.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the closest I can get to what you want is below.&lt;/P&gt;
&lt;P&gt;A slight issue is that DAX cannot work recursively.&lt;/P&gt;
&lt;P&gt;So we can calculate:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Average (Week 5) = Average of weeks 1-4 (actual data)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;But we can't then recursively calculate&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Average (Week 6) = Average of weeks 2-4 (actual data) &amp;amp; Average (Week 5)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;That is, the moving average can look at previous 4 weeks of actual data, but it can't incorporate the average for a previous week in a later week's average.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the below code, PreviousWeeksAverage is calculated over the previous 4 weeks of actual data (where data exists):&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Zero Rate Dollar Work = 
IF (
    HASONEVALUE ( 'Calendar'[start date] ) -- single week filtered
        &amp;amp;&amp;amp; HASONEVALUE ( ST_PFP_Report[AssignedTechnicians] ), -- single Technician filtered
        -- Get the previous 4 weeks (before the single filtered week)
    VAR PreviousFourWeeks =
        WINDOW ( -1, REL, -4, REL, ALL ( 'Calendar'[start date] ) )

    -- Determine if the current Technician
    -- appeared in the previous 4 weeks
    VAR ExistsInPreviousFourWeeks =
        CALCULATE (
            NOT ISEMPTY ( ST_PFP_Report ),
            ALL ( 'Calendar' ), -- clear 'Calendar' filters (technically not needed as 'Calendar' is in expanded ST_PFP_Report table)
            PreviousFourWeeks -- filter on Previous 4 weeks
        )
    VAR Result =
        IF (
            ExistsInPreviousFourWeeks, -- True/False
            -- Option 1: Calculation based on previous 4 weeks
            VAR PreviousWeeksAvg =
                CALCULATE (

                    -- This AVERAGEX expression averages (R_S_E + C_S_E + R_Z_act hrs + C_Z_Act Hrs) / Hours on task
                    -- over the previous 4 weeks.
                    AVERAGEX (
                        VALUES ( 'Calendar'[start date] ),
                        DIVIDE (
                            [R_S_E] + [C_S_E] + [R_Z_ Act Hrs] + [C_Z_Act Hrs],
                            [Hours On Task]
                        )
                    ),

                    ALL ( 'Calendar' ), -- clear 'Calendar' filters (technically not needed as 'Calendar' is in expanded ST_PFP_Report table)
                    PreviousFourWeeks -- filter on Previous 4 weeks
                )
            RETURN
                DIVIDE (
                    [R_S_E] + [C_S_E] + [R_Z_ Act Hrs] * PreviousWeeksAvg
                    + [C_Z_Act Hrs] * PreviousWeeksAvg,
                    [Hours On Task]
                ),
            -- Option 2: General formula
            DIVIDE (
                [R_S_E] + [C_S_E] + [R_Z_ Act Hrs] + [C_Z_Act Hrs],
                [Hours On Task]
            )
        )
    RETURN
        Result
)&lt;/LI-CODE&gt;
&lt;P&gt;That's about the best I can do at the moment. If it's not quite right, I hope you can modify it appropriately.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best,&lt;/P&gt;
&lt;P&gt;Owen&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 12:53:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3331285#M124836</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-07-14T12:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation of 4 weeks Rolling average based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3331306#M124840</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for the solution you were like oasis in the desert that had solved my issue,&lt;BR /&gt;Thanks a tones!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 13:08:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculation-of-4-weeks-Rolling-average-based-on-condition/m-p/3331306#M124840</guid>
      <dc:creator>Learner27</dc:creator>
      <dc:date>2023-07-14T13:08:56Z</dc:date>
    </item>
  </channel>
</rss>

