<?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 5 weeks except certain week in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-5-weeks-except-certain-week/m-p/2669726#M79554</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hi John - thanks for your input but the results are identical to the original measure. Although the issue could be that I can't use SELECTEDVALUE as the tool must be in excel but my understanding is SELECTEDVALUE can be replicated with other functions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;5 week average :=
VAR avg_5wk =
    CALCULATE (
        AVERAGEX ( fact, fact[units] ),
        DATESINPERIOD ( DimDate[pk_date], LASTDATE ( DimDate[pk_date] ), -34, DAY ),
        DimDate[YYYYWK]
            &amp;lt;&amp;gt; IF (
                HASONEVALUE ( slicer_table[YYYYWK] ),
                VALUES ( slicer_table[YYYYWK] )
            )
    )
RETURN
    avg_5wk&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In case you may ask, the data types for [YYYYWW] (i.e. 202229) in my date and slicer table are INT.&lt;/P&gt;&lt;P&gt;I've thought about this for some time and it's been quite a challenge to skip a week and still get a 5 week rolling average - let me know if I can clarify further.&lt;/P&gt;</description>
    <pubDate>Fri, 29 Jul 2022 14:30:17 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-07-29T14:30:17Z</dc:date>
    <item>
      <title>Avg 5 weeks except certain week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-5-weeks-except-certain-week/m-p/2668045#M79446</link>
      <description>&lt;P&gt;I have a measure that averages the last 5 weeks but I now need to exclude a week in my calculation and have it average the last 5 weeks dynamically . The week number is user driven.&lt;/P&gt;&lt;P&gt;i.e. user wants to exclude week 29 because it's too high, it should get the average of week 24 through 28 which is 1,502.&amp;nbsp;&lt;/P&gt;&lt;P&gt;week 30 should be the average of week 25, 26, 27, 28, 30&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;wk no&amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;units&amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;5 wk avg&amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;goal - 5 wk avg exclude wk 29&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;1,864&lt;/TD&gt;&lt;TD&gt;1,601&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;TD&gt;1,528&lt;/TD&gt;&lt;TD&gt;1,625&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;1,462&lt;/TD&gt;&lt;TD&gt;1,642&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;TD&gt;1,370&lt;/TD&gt;&lt;TD&gt;1,634&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;26&lt;/TD&gt;&lt;TD&gt;1,849&lt;/TD&gt;&lt;TD&gt;1,615&lt;/TD&gt;&lt;TD&gt;1,615&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;27&lt;/TD&gt;&lt;TD&gt;1,497&lt;/TD&gt;&lt;TD&gt;1,541&lt;/TD&gt;&lt;TD&gt;1,541&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;28&lt;/TD&gt;&lt;TD&gt;1,330&lt;/TD&gt;&lt;TD&gt;1,502&lt;/TD&gt;&lt;TD&gt;1,502&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT face="arial black,avant garde"&gt;29&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;9,586&lt;/TD&gt;&lt;TD&gt;3,126&lt;/TD&gt;&lt;TD&gt;&lt;FONT face="arial black,avant garde"&gt;1,502 (avg wk 24 - 28)&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;91&lt;/TD&gt;&lt;TD&gt;2,871&lt;/TD&gt;&lt;TD&gt;&lt;FONT face="arial black,avant garde"&gt;1,227 (avg wk&amp;nbsp;25, 26, 27, 28, 30)&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;5 week average:=&lt;BR /&gt;VAR avg_5wk =&lt;BR /&gt;CALCULATE (&lt;BR /&gt;AVERAGEX ( fact, fact[units] ),&lt;BR /&gt;DATESINPERIOD ( DimDate[pk_date], LASTDATE ( DimDate[pk_date] ), -34, DAY )&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;avg_5wk&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something I tried but didn't work was taking the user's week number and relating it to the date table with a calculated column that flags a 1. CALCULATE ( [5 week average], DimDate[WeekExclusion] &amp;lt;&amp;gt; 1 ) ) but this only works for that one week. How can I make it dynamic so that the results are like the table above?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 20:01:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-5-weeks-except-certain-week/m-p/2668045#M79446</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-07-28T20:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: Avg 5 weeks except certain week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-5-weeks-except-certain-week/m-p/2669018#M79511</link>
      <description>&lt;P&gt;You could try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;5 week average :=
VAR avg_5wk =
    CALCULATE (
        AVERAGEX ( fact, fact[units] ),
        DATESINPERIOD ( DimDate[pk_date], LASTDATE ( DimDate[pk_date] ), -34, DAY ),
        DimDate[Week no] &amp;lt;&amp;gt; SELECTEDVALUE ( 'Slicer Table'[Week no] )
    )
RETURN
    avg_5wk&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 29 Jul 2022 08:53:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-5-weeks-except-certain-week/m-p/2669018#M79511</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2022-07-29T08:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: Avg 5 weeks except certain week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-5-weeks-except-certain-week/m-p/2669726#M79554</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi John - thanks for your input but the results are identical to the original measure. Although the issue could be that I can't use SELECTEDVALUE as the tool must be in excel but my understanding is SELECTEDVALUE can be replicated with other functions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;5 week average :=
VAR avg_5wk =
    CALCULATE (
        AVERAGEX ( fact, fact[units] ),
        DATESINPERIOD ( DimDate[pk_date], LASTDATE ( DimDate[pk_date] ), -34, DAY ),
        DimDate[YYYYWK]
            &amp;lt;&amp;gt; IF (
                HASONEVALUE ( slicer_table[YYYYWK] ),
                VALUES ( slicer_table[YYYYWK] )
            )
    )
RETURN
    avg_5wk&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In case you may ask, the data types for [YYYYWW] (i.e. 202229) in my date and slicer table are INT.&lt;/P&gt;&lt;P&gt;I've thought about this for some time and it's been quite a challenge to skip a week and still get a 5 week rolling average - let me know if I can clarify further.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 14:30:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-5-weeks-except-certain-week/m-p/2669726#M79554</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-07-29T14:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: Avg 5 weeks except certain week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-5-weeks-except-certain-week/m-p/2669743#M79555</link>
      <description>&lt;P&gt;Try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;5 week average =
VAR fullDates =
    DATESINPERIOD ( DimDate[pk_date], LASTDATE ( DimDate[pk_date] ), -34, DAY )
VAR slicerDates =
    CALCULATETABLE (
        VALUES ( DimDate[pk_date] ),
        TREATAS ( VALUES ( slicer_table[YYYWK] ), DimDate[YYYWK] )
    )
RETURN
    CALCULATE (
        AVERAGE ( fact[units] ),
        TREATAS ( EXCEPT ( fullDates, slicerDates ), DimDate[pk_date] )
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 29 Jul 2022 14:40:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-5-weeks-except-certain-week/m-p/2669743#M79555</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2022-07-29T14:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: Avg 5 weeks except certain week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-5-weeks-except-certain-week/m-p/2669992#M79571</link>
      <description>&lt;P&gt;I got frustrated with the lack of functions in power pivot and put the whole thing in power bi to see if I can get it to work.&lt;/P&gt;&lt;P&gt;Tried the first measure again with SELECTEDVALUE but it's the same as my original measure.&lt;/P&gt;&lt;P&gt;Your second suggestion with TREATAS appears to be doing the same as SUM ( fact[units] ) when filtered on one sku but it seems to divide that by the number of skus I select. If week 30 is 100 and I have 5 skus filtered, it's 20.&lt;/P&gt;&lt;P&gt;Also, this is may be nothing but I noticed that TREATAS wasn't being picked up by the intellisense even though your measure is valid.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 17:15:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-5-weeks-except-certain-week/m-p/2669992#M79571</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-07-29T17:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: Avg 5 weeks except certain week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-5-weeks-except-certain-week/m-p/2681125#M80297</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Is your problem solved?? If so, Would you mind accept the helpful replies as solutions? Then we are able to close the thread. More people who have the same requirement will find the solution quickly and benefit here. Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Community Support Team _ kalyj&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 09:09:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-5-weeks-except-certain-week/m-p/2681125#M80297</guid>
      <dc:creator>v-yanjiang-msft</dc:creator>
      <dc:date>2022-08-04T09:09:18Z</dc:date>
    </item>
  </channel>
</rss>

