<?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: Dynamic 4 week average based on selected week in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-4-week-average-based-on-selected-week/m-p/1490491#M28632</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;Thanks, I adapted your DAX to my data model and with a few edits got it working:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Run Rate Dynamic = CALCULATE([Visits],FILTER(ALL('Calendar'),'Calendar'[Week Index]&amp;gt;=MAX('Calendar'[Week Index])-4 &amp;amp;&amp;amp; 'Calendar'[Week Index]&amp;lt;=MAX('Calendar'[Week Index])-1))/4&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 12 Nov 2020 14:02:17 GMT</pubDate>
    <dc:creator>AdamRobC</dc:creator>
    <dc:date>2020-11-12T14:02:17Z</dc:date>
    <item>
      <title>Dynamic 4 week average based on selected week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-4-week-average-based-on-selected-week/m-p/1490397#M28622</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please refer to the screenshot below. I have a static Run Rate DAX measure based on RelativeWeeks between -2 and -5 (where current week = 0), but I would like a dynamic Run Rate measure based on a Week Index. When a Fiscal Week is selected, it looks back at the previous 4 weeks and calculates the average across that period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;E.g. Run Rate Visits where Week Index = 135 would be the sum of visits between Week Indexes 131 and 134)&lt;/P&gt;&lt;P&gt;&amp;nbsp;= SUM(1679030+1536445+1499992+1341368) / 4 = 1,514,209 visits&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Adam&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 12:51:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-4-week-average-based-on-selected-week/m-p/1490397#M28622</guid>
      <dc:creator>AdamRobC</dc:creator>
      <dc:date>2020-11-12T12:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic 4 week average based on selected week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-4-week-average-based-on-selected-week/m-p/1490438#M28623</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="147069" data-lia-user-login="AdamRobC" class="lia-mention lia-mention-user"&gt;AdamRobC&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Please try the following measure:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Run Rate Dynamic = 

CALCULATE(
    AVERAGE(Table[Visits]),
    FILTER(
        ALL(Table),
        Table[RelativeWeek] &amp;lt; Max(Table[RelativeWeek]) &amp;amp;&amp;amp;  Table[RelativeWeek] &amp;gt;= Max(Table[RelativeWeek]) - 4
    )
)&lt;/LI-CODE&gt;&lt;P&gt;________________________&lt;/P&gt;&lt;P&gt;If my answer was helpful, please consider &lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&lt;I&gt; to help the other members find it&lt;/I&gt;&lt;/P&gt;&lt;P&gt;Click on the &lt;STRONG&gt;Thumbs-Up icon &lt;/STRONG&gt;if you like this reply &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.youtube.com/channel/UCKwBEguA8IlBubIobaOormg?sub_confirmation=1" target="_blank"&gt;&lt;FONT color="blue"&gt;YouTube&lt;/FONT&gt;&lt;/A&gt;&amp;nbsp; &lt;A href="https://linkedin.com/in/fowmy" target="_blank"&gt;&lt;FONT color="blue"&gt;LinkedIn&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 13:18:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-4-week-average-based-on-selected-week/m-p/1490438#M28623</guid>
      <dc:creator>Fowmy</dc:creator>
      <dc:date>2020-11-12T13:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic 4 week average based on selected week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-4-week-average-based-on-selected-week/m-p/1490444#M28625</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="147069" data-lia-user-login="AdamRobC" class="lia-mention lia-mention-user"&gt;AdamRobC&lt;/a&gt; , Assuming week index is same as week rank column &lt;/P&gt;
&lt;P&gt;Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)// Always incremental &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you can try measures like&lt;/P&gt;
&lt;P&gt;Last 4 weeks = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]&amp;gt;=max('Date'[Week Rank])-4 &amp;amp;&amp;amp; 'Date'[Week Rank]&amp;lt;=max('Date'[Week Rank])))&lt;BR /&gt;This Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))&lt;BR /&gt;Last Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))&lt;BR /&gt;Last year Week= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=(max('Date'[Week Rank]) -52)))&lt;BR /&gt;&lt;BR /&gt;last two weeks = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]&amp;lt;=max('Date'[Week Rank])-1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Power BI — Week on Week and WTD &lt;BR /&gt;&lt;A href="https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3" target="_blank"&gt;https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 13:22:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-4-week-average-based-on-selected-week/m-p/1490444#M28625</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-11-12T13:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic 4 week average based on selected week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-4-week-average-based-on-selected-week/m-p/1490446#M28626</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="147069" data-lia-user-login="AdamRobC" class="lia-mention lia-mention-user"&gt;AdamRobC&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may try the following measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Last 4 weeks Avg = 
VAR _CurrentWeek = MAX(dtTable[Week Index])
VAR _Filter = 
    FILTER(
        ALL(dtTable[Week Index]),
            dtTable[Week Index] &amp;gt;= _CurrentWeek-4
                &amp;amp;&amp;amp; dtTable[Week Index] &amp;lt;= _CurrentWeek-1
    )
VAR _Average = CALCULATE(AVERAGE(dtTable[Value]),_Filter)
RETURN
_Average&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers!&lt;BR /&gt;Vivek&lt;BR /&gt;&lt;BR /&gt;If it helps, please mark it as a solution. Kudos would be a cherry on the top &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;If it doesn't, then please share a sample data along with the expected results (preferably an excel file and not an image)&lt;BR /&gt;&lt;BR /&gt;Blog: &lt;A href="https://www.vivran.in/my-blog" target="_blank"&gt;vivran.in/my-blog&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.linkedin.com/in/vivek-ranjan-063a1a17b/" target="_blank"&gt;Connect on LinkedIn&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://twitter.com/imvivran" target="_blank"&gt;Follow on Twitter&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 13:22:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-4-week-average-based-on-selected-week/m-p/1490446#M28626</guid>
      <dc:creator>vivran22</dc:creator>
      <dc:date>2020-11-12T13:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic 4 week average based on selected week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-4-week-average-based-on-selected-week/m-p/1490487#M28631</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="52518" data-lia-user-login="Fowmy" class="lia-mention lia-mention-user"&gt;Fowmy&lt;/a&gt;&amp;nbsp;Thanks, but relative date is calculated based on the current week, I need the measure to be dynamic based on a user-selected week, so using Week Index instead.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 13:49:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-4-week-average-based-on-selected-week/m-p/1490487#M28631</guid>
      <dc:creator>AdamRobC</dc:creator>
      <dc:date>2020-11-12T13:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic 4 week average based on selected week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-4-week-average-based-on-selected-week/m-p/1490491#M28632</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;Thanks, I adapted your DAX to my data model and with a few edits got it working:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Run Rate Dynamic = CALCULATE([Visits],FILTER(ALL('Calendar'),'Calendar'[Week Index]&amp;gt;=MAX('Calendar'[Week Index])-4 &amp;amp;&amp;amp; 'Calendar'[Week Index]&amp;lt;=MAX('Calendar'[Week Index])-1))/4&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 12 Nov 2020 14:02:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-4-week-average-based-on-selected-week/m-p/1490491#M28632</guid>
      <dc:creator>AdamRobC</dc:creator>
      <dc:date>2020-11-12T14:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic 4 week average based on selected week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-4-week-average-based-on-selected-week/m-p/1490509#M28634</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="147069" data-lia-user-login="AdamRobC" class="lia-mention lia-mention-user"&gt;AdamRobC&lt;/a&gt; , missed placed parentheses &lt;/P&gt;
&lt;P&gt;Run Rate Dynamic = CALCULATE(SUM([Visits]),FILTER(ALL('Calendar'),'Calendar'[Week Index]&amp;gt;=MAX('Calendar'[Week Index])-4 &amp;amp;&amp;amp; 'Calendar'[Week Index]&amp;lt;=MAX('Calendar'[Week Index])))&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 14:01:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-4-week-average-based-on-selected-week/m-p/1490509#M28634</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-11-12T14:01:35Z</dc:date>
    </item>
  </channel>
</rss>

