<?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: 3-year rolling average issue in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/3-year-rolling-average-issue/m-p/4586260#M175705</link>
    <description>&lt;P&gt;This is another measure I have tried, but this just gives me the yearly average rather than a 3-year RA:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR Jaargemiddelden = 
    SUMMARIZE(
        'Sorteerproeven data SharePoint List',
        Datum[Jaar],
        "JaarGemiddeldeDeelstroom", [Yearly average per subcomponent]
    )
RETURN
    CALCULATE(
        AVERAGEX(Jaargemiddelden, [JaarGemiddeldeDeelstroom]),
        DATESINPERIOD(
            'Datum'[Date],
            MAX('Datum'[Date]),
            -3,
            YEAR
        ),
        ALLEXCEPT('Sorteerproeven data SharePoint List', 'Sorteerproeven data SharePoint List'[Grouping components Residual], 'Sorteerproeven data SharePoint List'[Component], 'Sorteerproeven data SharePoint List'[subcomponent])
    )&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 26 Feb 2025 15:15:10 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2025-02-26T15:15:10Z</dc:date>
    <item>
      <title>3-year rolling average issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/3-year-rolling-average-issue/m-p/4586254#M175704</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have two tables:&lt;/P&gt;&lt;P&gt;1. Date table&lt;/P&gt;&lt;P&gt;2. Table containing data on sorting analysis of residual household waste. We look at this to determine the recycle potential. This table contains the percentage of a certain waste stream found in the garbage for a specific waste analysis. These are the columns:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The percentages are calculated for each subcomponent. Some components consist of several subcomponents. The last column groups the components into groups. The date column contains the date of the specific waste analysis.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The two tables are linked through the date column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The sorting analysis table contains data from 2019 through 2024. For 2019 until 2023, i have one sorting analysis per year, so 1 percentage per subcomponent per year. However, in 2024 I have 3 waste analyses, so 3 percentages per component per year.&lt;BR /&gt;&lt;BR /&gt;I calculated the yearly average using this DAX measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Yearly average per subcomponent = 
CALCULATE(
    AVERAGE('Sorteerproeven data SharePoint List'[Percentage (van kilo's)]),
    ALLEXCEPT('Sorteerproeven data SharePoint List', 'Sorteerproeven data SharePoint List'[Grouping components Residual], 'Sorteerproeven data SharePoint List'[Component], 'Sorteerproeven data SharePoint List'[Subcomponent], Datum[Jaar])
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This gives me the correct result per subcomponent, however, when viewing these numbers in a matrix, the components and grouped components are wrong, since that will also be an average, whearas I need that to be the sum. This measure works to solve that issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Yearly average per component = 
SUMX(
    SUMMARIZE(
        'Sorteerproeven data SharePoint List',
        'Sorteerproeven data SharePoint List'[Component],
        'Sorteerproeven data SharePoint List'[Subcomponent],
        "JaarGemiddeldeDeelstroom", [Yearly average per subcomponent]
    ),
    [Yearly average per subcomponent]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This last measure gives me the correct yearly average for each subcomponent, component and grouped components.&lt;BR /&gt;&lt;BR /&gt;However, now we arrive at my issue. I want to calculate a 3-year rolling average of those yearly averages. I have tried so many different variations and discussed it endlessly with Copilot, but I ended up in a loop where it kept on giving me the same measures that had issues.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This measure is the closest to the correct answer for the 3-year RA per subcomponent:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;3-year rolling average per subcomponent = 
CALCULATE(
    SUM('Sorteerproeven data SharePoint List'[Percentage (van kilo's)]) / COUNT('Sorteerproeven data SharePoint List'[Percentage (van kilo's)]),
    DATESINPERIOD(
        'Datum'[Date],
        MAX('Datum'[Date]),
        -3,
        YEAR
    ),
    ALLEXCEPT('Sorteerproeven data SharePoint List', 'Sorteerproeven data SharePoint List'[Grouping components Residual], 'Sorteerproeven data SharePoint List'[Component], 'Sorteerproeven data SharePoint List'[Subcomponent])
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The weird thing is that this gives me the correct 3-year ROA for 2021, 2022 and 2023, where I only have one sorting analysis per year, but it is incorrect for 2024, when I have several sorting analyses per year. I cannot figure out why it isn't working or what the solution is, so I would be very grateful for some help. I have a .pbix file I can share, but I don't know how to attach it to this message.&lt;BR /&gt;&lt;BR /&gt;After having figured out the correct 3-year RA per subcomponent, I still have to get the correct number per component and grouped components, but I am hoping the same SUMX( SUMMARIZE( will work as for the yearly averages.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks in advance!&lt;BR /&gt;&lt;BR /&gt;Edit:&lt;BR /&gt;This is a wetransfer link to the file:&amp;nbsp;&lt;A href="https://we.tl/t-8v1ptSUvW6" target="_blank" rel="noopener"&gt;https://we.tl/t-8v1ptSUvW6&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 15:18:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/3-year-rolling-average-issue/m-p/4586254#M175704</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-02-26T15:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: 3-year rolling average issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/3-year-rolling-average-issue/m-p/4586260#M175705</link>
      <description>&lt;P&gt;This is another measure I have tried, but this just gives me the yearly average rather than a 3-year RA:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR Jaargemiddelden = 
    SUMMARIZE(
        'Sorteerproeven data SharePoint List',
        Datum[Jaar],
        "JaarGemiddeldeDeelstroom", [Yearly average per subcomponent]
    )
RETURN
    CALCULATE(
        AVERAGEX(Jaargemiddelden, [JaarGemiddeldeDeelstroom]),
        DATESINPERIOD(
            'Datum'[Date],
            MAX('Datum'[Date]),
            -3,
            YEAR
        ),
        ALLEXCEPT('Sorteerproeven data SharePoint List', 'Sorteerproeven data SharePoint List'[Grouping components Residual], 'Sorteerproeven data SharePoint List'[Component], 'Sorteerproeven data SharePoint List'[subcomponent])
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 26 Feb 2025 15:15:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/3-year-rolling-average-issue/m-p/4586260#M175705</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-02-26T15:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: 3-year rolling average issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/3-year-rolling-average-issue/m-p/4586952#M175725</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try this measure:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;3-year rolling average per subcomponent =
VAR _CurrentYear =
    YEAR ( MAX ( 'Datum'[Date] ) )
VAR Jaargemiddelden =
    SUMMARIZE (
        'Sorteerproeven data SharePoint List',
        Datum[Jaar],
        "JaarGemiddeldeDeelstroom", [Yearly average per subcomponent]
    )
RETURN
    CALCULATE (
        AVERAGEX ( Jaargemiddelden, [JaarGemiddeldeDeelstroom] ),
        FILTER (
            ALLSELECTED ( 'Datum' ),
            YEAR ( 'Datum'[Date] ) &amp;lt;= _CurrentYear
                &amp;amp;&amp;amp; YEAR ( 'Datum'[Date] ) &amp;gt;= _CurrentYear - 3
        ),
        ALLEXCEPT (
            'Sorteerproeven data SharePoint List',
            'Sorteerproeven data SharePoint List'[Grouping components Residual],
            'Sorteerproeven data SharePoint List'[Component],
            'Sorteerproeven data SharePoint List'[subcomponent]
        )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this can help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Zhengdong Xu&lt;BR /&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 01:53:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/3-year-rolling-average-issue/m-p/4586952#M175725</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-02-27T01:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: 3-year rolling average issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/3-year-rolling-average-issue/m-p/4587520#M175739</link>
      <description>&lt;P&gt;Hi Zhendong, thank you for taking the time to reply! I have tried your measure, however, this gives me the yearly averages rather than the three-year rolling average:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 08:55:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/3-year-rolling-average-issue/m-p/4587520#M175739</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-02-27T08:55:12Z</dc:date>
    </item>
  </channel>
</rss>

