<?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: AVG year to date, starting from december in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AVG-year-to-date-starting-from-december/m-p/1932867#M41981</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="246672" data-lia-user-login="Lars_c" class="lia-mention lia-mention-user"&gt;Lars_c&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even though you're working with the month granularity, your Dates table should contain all days. Then, you can hide the granularity below the month but it's imperative for time-intel in PBI to work correctly that the table be on the day granularity. If you ignore this rule today, you'll just shifting the refactoring/resolution into the future. And then it may be much harder to refactor. But it's up to you &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;To do what you want, you should number your months within the year from 1 to 12. Once you have this ordering, it's rather easy to write a measure that will include December last year (together with any conditional logic you want).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The filter you need will then look something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var MaxVisibleMonth = MAX( Dates[MonthNumber] )
var MaxVisibleYear = MAX( Dates[Year] )
var Result =
    CALCULATE(
        [Your Measure],
        filter(
            ALL( Dates[MonthNumber], Dates[Year] ),
            (
                Dates[MonthNumber] &amp;lt;= MaxVisibleMonth
                &amp;amp;&amp;amp; 
                // Year must be an int. If it's
                // not, then you have to have
                // an int column that will store
                // the year as an int.
                Dates[Year] = MaxVisibleYear
            )
            ||
            (
                Dates[MonthNumber] = 12
                &amp;amp;&amp;amp;
                Dates[Year] = MaxVisibleYear - 1
            )
        ),
        REMOVEFILTERS( Dates )
    )
return
    Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Jul 2021 13:58:42 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-07-01T13:58:42Z</dc:date>
    <item>
      <title>AVG year to date, starting from december</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AVG-year-to-date-starting-from-december/m-p/1930070#M41896</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A customer has a series of very specific calculations for some of the Year-to-date values.&lt;/P&gt;&lt;P&gt;Right now, for most of the values, i calculate the average between the values with this formula:&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;[MTH] are the monthly values, 'Dates' is my date-table.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Calculate( Averagex (Dates, [MTH] ),&lt;/P&gt;&lt;P&gt;Filter(all(Dates), Dates[Dates] &amp;lt;= max (Dates[Dates]) &amp;amp;&amp;amp; Dates[Year] = max(Dates[Year])&lt;/P&gt;&lt;P&gt;))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This returns for March: (Jan+Feb+March)/3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem starts with another KPI, which uses the value from December of the previous year as well.&lt;/P&gt;&lt;P&gt;Example for March: (Dec(LY)+Jan+Feb+March)/4&lt;/P&gt;&lt;P&gt;Note, for december in the current year, the calculation goes: (Dec(LY)+Jan+Feb+...+Nov+Dec)/13&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't seem to get to my formula starting from december, any help?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 07:56:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AVG-year-to-date-starting-from-december/m-p/1930070#M41896</guid>
      <dc:creator>Lars_c</dc:creator>
      <dc:date>2021-06-30T07:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: AVG year to date, starting from december</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AVG-year-to-date-starting-from-december/m-p/1931379#M41940</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="246672" data-lia-user-login="Lars_c" class="lia-mention lia-mention-user"&gt;Lars_c&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks to me that the formula you've shown calculates a daily average, not a monthly. You are iterating the Date table in AVERAGEX, so you're iterating on the daily granularity, not the monthly. Why do you say it calculates some kind of monthly average?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 16:50:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AVG-year-to-date-starting-from-december/m-p/1931379#M41940</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-06-30T16:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: AVG year to date, starting from december</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AVG-year-to-date-starting-from-december/m-p/1931831#M41960</link>
      <description>&lt;LI-CODE lang="markup"&gt;DATESYTD( Calendar[Date], "11/30" )&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 30 Jun 2021 23:06:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AVG-year-to-date-starting-from-december/m-p/1931831#M41960</guid>
      <dc:creator>CNENFRNL</dc:creator>
      <dc:date>2021-06-30T23:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: AVG year to date, starting from december</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AVG-year-to-date-starting-from-december/m-p/1932516#M41977</link>
      <description>&lt;P&gt;Hello&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do filter it with 'calculate', which results in only one value each month. I only have values for one day of the month since month is the smallest granularity.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem seems to me with my filter evaluation, where i say:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;amp;&amp;amp; Dates[Year] = max(Dates[Year])&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It should contain the month before as well.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 07:45:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AVG-year-to-date-starting-from-december/m-p/1932516#M41977</guid>
      <dc:creator>Lars_c</dc:creator>
      <dc:date>2021-07-01T07:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: AVG year to date, starting from december</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AVG-year-to-date-starting-from-december/m-p/1932867#M41981</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="246672" data-lia-user-login="Lars_c" class="lia-mention lia-mention-user"&gt;Lars_c&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even though you're working with the month granularity, your Dates table should contain all days. Then, you can hide the granularity below the month but it's imperative for time-intel in PBI to work correctly that the table be on the day granularity. If you ignore this rule today, you'll just shifting the refactoring/resolution into the future. And then it may be much harder to refactor. But it's up to you &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;To do what you want, you should number your months within the year from 1 to 12. Once you have this ordering, it's rather easy to write a measure that will include December last year (together with any conditional logic you want).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The filter you need will then look something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var MaxVisibleMonth = MAX( Dates[MonthNumber] )
var MaxVisibleYear = MAX( Dates[Year] )
var Result =
    CALCULATE(
        [Your Measure],
        filter(
            ALL( Dates[MonthNumber], Dates[Year] ),
            (
                Dates[MonthNumber] &amp;lt;= MaxVisibleMonth
                &amp;amp;&amp;amp; 
                // Year must be an int. If it's
                // not, then you have to have
                // an int column that will store
                // the year as an int.
                Dates[Year] = MaxVisibleYear
            )
            ||
            (
                Dates[MonthNumber] = 12
                &amp;amp;&amp;amp;
                Dates[Year] = MaxVisibleYear - 1
            )
        ),
        REMOVEFILTERS( Dates )
    )
return
    Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 13:58:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/AVG-year-to-date-starting-from-december/m-p/1932867#M41981</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-01T13:58:42Z</dc:date>
    </item>
  </channel>
</rss>

