<?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 the difference between yearly averages, for each individual user in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-difference-between-yearly-averages-for-each/m-p/2143248#M49277</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;Hi!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you paste as a comment the table on which to calculate the required measurement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx,&lt;/P&gt;&lt;P&gt;B.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Oct 2021 13:04:23 GMT</pubDate>
    <dc:creator>BeaBF</dc:creator>
    <dc:date>2021-10-19T13:04:23Z</dc:date>
    <item>
      <title>Calculate the difference between yearly averages, for each individual user</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-difference-between-yearly-averages-for-each/m-p/2143035#M49270</link>
      <description>&lt;P&gt;&lt;SPAN&gt;The following is a sample user dataset where each user is assigned a rating at random times during the year (Some users are missing ratings for some of the years).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;img /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have a matrix visual with the average rating per user, per year. (See example below). So John Smith had 2 enteries for the year 2020 and the matrix has a single average value for that user, for each year that they have data for.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;img /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What I'm trying to achieve is the Diff coloum (last coloum in 2nd visual), which is the difference between the 'latest average yearly rating' and 'earliest&amp;nbsp;average yearly rating'. In Johns case this will be&amp;nbsp;1.225-0.936 (his value in 2021-2019). So "the earliest year" and "the latest year" with data could be different for each user.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I calculate this coloum/ measure with DAX?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Any help is much appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 11:41:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-difference-between-yearly-averages-for-each/m-p/2143035#M49270</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-19T11:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the difference between yearly averages, for each individual user</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-difference-between-yearly-averages-for-each/m-p/2143248#M49277</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;Hi!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you paste as a comment the table on which to calculate the required measurement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx,&lt;/P&gt;&lt;P&gt;B.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 13:04:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-difference-between-yearly-averages-for-each/m-p/2143248#M49277</guid>
      <dc:creator>BeaBF</dc:creator>
      <dc:date>2021-10-19T13:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the difference between yearly averages, for each individual user</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-difference-between-yearly-averages-for-each/m-p/2144030#M49305</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp; to be able to achieve this, you would need a Calendar Table. Once you have that, create a relationship between Fact[Date] and Calendar[Calendar_Date] which will look like below&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Then you can write the following meaure to achieve what you need&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
VAR _mxYear =
    CALCULATE (
        CALCULATE (
            MAX ( 'Calendar'[Calendar_Year] ),
            ALLEXCEPT ( 'Fact', 'Fact'[ID] )
        ),
        CROSSFILTER ( 'Fact'[Date], 'Calendar'[Calendar_Date], BOTH )
    )
VAR _minYear =
    CALCULATE (
        CALCULATE (
            MIN ( 'Calendar'[Calendar_Year] ),
            ALLEXCEPT ( 'Fact', 'Fact'[ID] )
        ),
        CROSSFILTER ( 'Fact'[Date], 'Calendar'[Calendar_Date], BOTH )
    )
VAR _minAvg =
    CALCULATE (
        AVERAGE ( 'Fact'[Rating] ),
        FILTER (
            VALUES ( 'Calendar'[Calendar_Year] ),
            'Calendar'[Calendar_Year] = _minYear
        )
    )
VAR _maxAvg =
    CALCULATE (
        AVERAGE ( 'Fact'[Rating] ),
        FILTER (
            VALUES ( 'Calendar'[Calendar_Year] ),
            'Calendar'[Calendar_Year] = _mxYear
        )
    )
RETURN
    _maxAvg - _minAvg&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 20:04:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-difference-between-yearly-averages-for-each/m-p/2144030#M49305</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2021-10-19T20:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the difference between yearly averages, for each individual user</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-difference-between-yearly-averages-for-each/m-p/2155098#M49744</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="24978" data-lia-user-login="smpa01" class="lia-mention lia-mention-user"&gt;smpa01&lt;/a&gt;!&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 07:26:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-difference-between-yearly-averages-for-each/m-p/2155098#M49744</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-26T07:26:46Z</dc:date>
    </item>
  </channel>
</rss>

