<?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 average of a rolling fixed day in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-average-of-a-rolling-fixed-day/m-p/2754638#M85111</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , You need have weekday and year column in date table with a measure value sum in model &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;try measure like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CALCULATE(&lt;BR /&gt;AVERAGEX(ALLSELECTED('DimDate'),[value sum])&lt;BR /&gt;Filter( 'DimDate' , ('DimDate'[weekday]) = (MAX('DimDate'[weekday])) &amp;amp;&amp;amp; ('DimDate'[year]) = (MAX('DimDate'[year])),&lt;BR /&gt;))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CALCULATE(&lt;BR /&gt;AVERAGEX(ALLSELECTED('DimDate'),[value sum])&lt;BR /&gt;Filter( 'DimDate' , weekday('DimDate'[Date]) = weekday(MAX('DimDate'[Date])) &amp;amp;&amp;amp; year('DimDate'[Date]) = year(MAX('DimDate'[Date])),&lt;BR /&gt;))&lt;/P&gt;</description>
    <pubDate>Thu, 08 Sep 2022 08:15:22 GMT</pubDate>
    <dc:creator>amitchandak</dc:creator>
    <dc:date>2022-09-08T08:15:22Z</dc:date>
    <item>
      <title>Calculate the average of a rolling fixed day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-average-of-a-rolling-fixed-day/m-p/2754485#M85098</link>
      <description>&lt;P&gt;How can you calculate the average of a fixed day? For example, only the average of the Mondays of the year. Below I have already made a calculation in which he takes the average of the course of days. I want to get this same rhythm from only fixed days.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;measure test = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;AVERAGEX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ALLSELECTED&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'DimDate'&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; &lt;/SPAN&gt;&lt;SPAN&gt;'DimDate'&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'DimDate'&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&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; &lt;/SPAN&gt;&lt;SPAN&gt;[value sum]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 08 Sep 2022 07:01:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-average-of-a-rolling-fixed-day/m-p/2754485#M85098</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-09-08T07:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the average of a rolling fixed day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-average-of-a-rolling-fixed-day/m-p/2754638#M85111</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , You need have weekday and year column in date table with a measure value sum in model &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;try measure like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CALCULATE(&lt;BR /&gt;AVERAGEX(ALLSELECTED('DimDate'),[value sum])&lt;BR /&gt;Filter( 'DimDate' , ('DimDate'[weekday]) = (MAX('DimDate'[weekday])) &amp;amp;&amp;amp; ('DimDate'[year]) = (MAX('DimDate'[year])),&lt;BR /&gt;))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CALCULATE(&lt;BR /&gt;AVERAGEX(ALLSELECTED('DimDate'),[value sum])&lt;BR /&gt;Filter( 'DimDate' , weekday('DimDate'[Date]) = weekday(MAX('DimDate'[Date])) &amp;amp;&amp;amp; year('DimDate'[Date]) = year(MAX('DimDate'[Date])),&lt;BR /&gt;))&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 08:15:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-average-of-a-rolling-fixed-day/m-p/2754638#M85111</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-09-08T08:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the average of a rolling fixed day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-average-of-a-rolling-fixed-day/m-p/2754702#M85117</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;[Measure for Mondays] =
// This variable can be made dynamic and can be harvested
// from an independent slicer. Here, I've hard-coded the
// day name but you get the gist, I hope.
var DayName = "monday"
var CurrentlyVisibleMaxDate = MAX( 'DimDate'[Date] )
var Output = 
    CALCULATE(
        AVERAGEX(
            FILTER(
                ALLSELECTED( 'DimDate' ),
                'DimDate'[Date] &amp;lt;= CurrentlyVisibleMaxDate,
                // Also to test, wrap this line in KEEPFILTERS to see
                // what's gonna happen, like so:
                // KEEPFILTERS( 'DimDate'[Day Name] = DayName )
                'DimDate'[Day Name] = DayName
            ),
            [value sum]
        )
    )
return
    Output&lt;/LI-CODE&gt;
&lt;P&gt;or this one (should be faster):&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;[Measure for Mondays] =
// This variable can be made dynamic and can be harvested
// from an independent slicer. Here, I've hard-coded the
// day name but you get the gist, I hope.
// By the way, DAX is case-insensitive.
var DayName = "monday"
var CurrentlyVisibleMaxDate = MAX( 'DimDate'[Date] )
var Output = 
    CALCULATE(
        AVERAGEX(
            VALUES( DimDate[Date] ),
            [value sum]
        ),
        'DimDate'[Date] &amp;lt;= CurrentlyVisibleMaxDate,
        // Also to test, wrap this line in KEEPFILTERS to see
        // what's gonna happen, like so:
        // KEEPFILTERS( 'DimDate'[Day Name] = DayName )
        'DimDate'[Day Name] = DayName,
        ALLSELECTED( 'DimDate' )
)
return
    Output&lt;/LI-CODE&gt;
&lt;P&gt;The second example is how it should be really written. First, the simple expression, then all the filters and directives to CALCULATE. This structure ensures not only clarity but also the fastest execution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 08:42:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-average-of-a-rolling-fixed-day/m-p/2754702#M85117</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-09-08T08:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the average of a rolling fixed day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-average-of-a-rolling-fixed-day/m-p/2754824#M85124</link>
      <description>&lt;P&gt;Thank you for your answer. The total correct of the answer only the measure does not apply to the records. In the rightmost column is how it should be.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 09:17:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-average-of-a-rolling-fixed-day/m-p/2754824#M85124</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-09-08T09:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the average of a rolling fixed day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-average-of-a-rolling-fixed-day/m-p/2766726#M85955</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;Approve with&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="349489" data-lia-user-login="daXtreme" class="lia-mention lia-mention-user"&gt;daXtreme&lt;/a&gt;&amp;nbsp;, if you want&amp;nbsp;&lt;SPAN&gt;make it variable, you can change the value of&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;var DayName&lt;/LI-CODE&gt;
&lt;P&gt;Here is my solution:&lt;/P&gt;
&lt;P&gt;Based on your description, I have created a simple sample:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = AVERAGEX(FILTER(ALL(DimDate),WEEKDAY([Date],2)=1&amp;amp;&amp;amp;[Date]&amp;lt;=MAX('DimDate'[Date])),[value sum])&lt;/LI-CODE&gt;
&lt;P&gt;You can change the fix day by changing&amp;nbsp;&lt;EM&gt;WEEKDAY([Date],2)=1&amp;nbsp;&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;Final output:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P style="background: white; margin: 7.5pt 0in 0in 0in;"&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="background: white; margin: 7.5pt 0in 0in 0in;"&gt;&lt;SPAN&gt;Jianbo Li&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="background: white; margin: 7.5pt 0in 0in 0in;"&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 09:22:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-average-of-a-rolling-fixed-day/m-p/2766726#M85955</guid>
      <dc:creator>v-jianboli-msft</dc:creator>
      <dc:date>2022-09-14T09:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the average of a rolling fixed day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-average-of-a-rolling-fixed-day/m-p/2766757#M85959</link>
      <description>&lt;P&gt;Thank you! I've already made it variable&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;DayName =&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;('DimDate week'[WeekDay])&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 09:28:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-average-of-a-rolling-fixed-day/m-p/2766757#M85959</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-09-14T09:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the average of a rolling fixed day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-average-of-a-rolling-fixed-day/m-p/2804987#M88417</link>
      <description>&lt;P&gt;Hi Daxtreme,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I made the [measure for monday] variable.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;DayName =&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;('DimDate week'[WeekDay]&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;How can you add up the outcome of the measure [measure for mondays]? So the figures from Monday to Sunday added together. To use it in a matrix.&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 06:02:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-average-of-a-rolling-fixed-day/m-p/2804987#M88417</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-09-29T06:02:49Z</dc:date>
    </item>
  </channel>
</rss>

