<?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: Problem with Moving Average 12 in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-Moving-Average-12/m-p/1333544#M23674</link>
    <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your answer.&lt;/P&gt;&lt;P&gt;The column FECHA that contains dates just have dates from monday to friday, however in the calculation is taking weekends as well (I Think because I'm using DATESINPERIOD).&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 29 Aug 2020 15:14:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-08-29T15:14:25Z</dc:date>
    <item>
      <title>Problem with Moving Average 12</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-Moving-Average-12/m-p/1333107#M23658</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an issue. I was trying to replicate the formula from this post:&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Desktop/5-Day-Moving-average-No-Weekends-in-Data-and-how-I-skip-weekends/m-p/133197#M56901" target="_blank"&gt;https://community.powerbi.com/t5/Desktop/5-Day-Moving-average-No-Weekends-in-Data-and-how-I-skip-weekends/m-p/133197#M56901&lt;/A&gt; in a Moving average of 12 data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have stocks information, then I just have information on weekdays, replicating this formula worked in moving average of 5, but I need to use it on 12 as well. Following is the formula:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Movil 12 = AVERAGEX(DATESINPERIOD(Tecnicos[FECHA],MAX(Tecnicos[FECHA]),-16,DAY),[Total Precios])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;The problem is that on mondays I get the wrong average, because counting 16 gets to a sunday (blank) and I need to get to the previous friday. But If I try to move the -16 to a -17 all the other averages will be wrong.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I tried looking for that information in many places I couldn't make it.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I aprecciate help.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 29 Aug 2020 00:37:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-Moving-Average-12/m-p/1333107#M23658</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-29T00:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Moving Average 12</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-Moving-Average-12/m-p/1333134#M23659</link>
      <description>&lt;P&gt;Hi, there&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Weekends are supposed to be filtered out in Tecnicos[FECHA] column beforehand;&lt;/P&gt;&lt;P&gt;or filter down&amp;nbsp;Tecnicos[FECHA] if it contains all consecutive dates&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_12workdays =
TOPN (
    12,
    CALCULATETABLE (
        VALUES ( Calendar[Date] ),
        NOT WEEKDAY ( Calendar[Date] ) IN { 1, 7 },
        FILTER ( ALL ( Calendar[Date] ), Calendar[Date] &amp;lt;= MAX ( Calendar[Date] ) )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Aug 2020 02:16:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-Moving-Average-12/m-p/1333134#M23659</guid>
      <dc:creator>CNENFRNL</dc:creator>
      <dc:date>2020-08-29T02:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Moving Average 12</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-Moving-Average-12/m-p/1333137#M23660</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;- One, I would personally avoid DATESINPERIOD.&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/To-bleep-With-DATEADD/m-p/1259467#M583" target="_blank"&gt;https://community.powerbi.com/t5/Quick-Measures-Gallery/To-bleep-With-DATEADD/m-p/1259467#M583&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may find this helpful - &lt;A href="https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008" target="_blank"&gt;https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally,&amp;nbsp;Not really enough information to go on, please first check if your issue is a common issue listed here: &lt;A href="https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Also, please see this post regarding How to Get Your Question Answered Quickly: &lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;The most important parts are:&lt;BR /&gt;1. Sample data as text, use the table tool in the editing bar&lt;BR /&gt;2. Expected output from sample data&lt;BR /&gt;3. Explanation in words of how to get from 1. to 2.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Aug 2020 02:16:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-Moving-Average-12/m-p/1333137#M23660</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-08-29T02:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Moving Average 12</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-Moving-Average-12/m-p/1333539#M23672</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your feedback.&lt;/P&gt;&lt;P&gt;I tried using the formulas, however I couldn't make it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using a lot of companies to analyze, my original chart has dates in rows and companies in columns, therefore I had to unpivot table to use it in BI properly, That's how my table looks like (unpivot)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;FECHA&lt;/TD&gt;&lt;TD&gt;Empresa&lt;/TD&gt;&lt;TD&gt;Price&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23/12/2009&lt;/TD&gt;&lt;TD&gt;Acerias&lt;/TD&gt;&lt;TD&gt;$39.40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23/12/2009&lt;/TD&gt;&lt;TD&gt;Isagen&lt;/TD&gt;&lt;TD&gt;$2,165.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23/12/2009&lt;/TD&gt;&lt;TD&gt;GrupoArgos&lt;/TD&gt;&lt;TD&gt;$18,980.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;24/12/2009&lt;/TD&gt;&lt;TD&gt;Acerias&lt;/TD&gt;&lt;TD&gt;$41.65&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;24/12/2009&lt;/TD&gt;&lt;TD&gt;Isagen&lt;/TD&gt;&lt;TD&gt;$2,200.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;24/12/2009&lt;/TD&gt;&lt;TD&gt;GrupoArgos&lt;/TD&gt;&lt;TD&gt;$19,000.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's an example. I have more than 2000 rows with more companies (Data since 2009)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I was using with the dateadd function was MovingAverage12 =&amp;nbsp;AVERAGEX(DATESINPERIOD(Tecnicos[FECHA],MAX(Tecnicos[FECHA]),-16,DAY),[Total Precios])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The table I am receiving is the next one:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;FECHA&lt;/TD&gt;&lt;TD&gt;Price&lt;/TD&gt;&lt;TD&gt;MovingAverage12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Friday, August 14, 2020&lt;/TD&gt;&lt;TD&gt;10,260.00&lt;/TD&gt;&lt;TD&gt;10,313.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Monday, August 17, 2020&lt;/TD&gt;&lt;TD&gt;10,260.00&lt;/TD&gt;&lt;TD&gt;10,315.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Tuesday, August 18, 2020&lt;/TD&gt;&lt;TD&gt;10,520.00&lt;/TD&gt;&lt;TD&gt;10,332.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Wednesday, August 19, 2020&lt;/TD&gt;&lt;TD&gt;10,660.00&lt;/TD&gt;&lt;TD&gt;10,357.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Thursday, August 20, 2020&lt;/TD&gt;&lt;TD&gt;10,740.00&lt;/TD&gt;&lt;TD&gt;10,402.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Friday, August 21, 2020&lt;/TD&gt;&lt;TD&gt;10,980.00&lt;/TD&gt;&lt;TD&gt;10,453.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Monday, August 24, 2020&lt;/TD&gt;&lt;TD&gt;11,320.00&lt;/TD&gt;&lt;TD&gt;10,549.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Tuesday, August 25, 2020&lt;/TD&gt;&lt;TD&gt;11,860.00&lt;/TD&gt;&lt;TD&gt;10,658.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Wednesday, August 26, 2020&lt;/TD&gt;&lt;TD&gt;11,820.00&lt;/TD&gt;&lt;TD&gt;10,785.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Thursday, August 27, 2020&lt;/TD&gt;&lt;TD&gt;11,900.00&lt;/TD&gt;&lt;TD&gt;10,920.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The values I'm looking for, are the following.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Friday, August 14, 2020&lt;/TD&gt;&lt;TD&gt;10,260.00&lt;/TD&gt;&lt;TD&gt;10,313.33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Monday, August 17, 2020&lt;/TD&gt;&lt;TD&gt;10,260.00&lt;/TD&gt;&lt;TD&gt;10,305.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Tuesday, August 18, 2020&lt;/TD&gt;&lt;TD&gt;10,520.00&lt;/TD&gt;&lt;TD&gt;10,331.67&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Wednesday, August 19, 2020&lt;/TD&gt;&lt;TD&gt;10,660.00&lt;/TD&gt;&lt;TD&gt;10,356.67&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Thursday, August 20, 2020&lt;/TD&gt;&lt;TD&gt;10,740.00&lt;/TD&gt;&lt;TD&gt;10,401.67&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Friday, August 21, 2020&lt;/TD&gt;&lt;TD&gt;10,980.00&lt;/TD&gt;&lt;TD&gt;10,453.33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Monday, August 24, 2020&lt;/TD&gt;&lt;TD&gt;11,320.00&lt;/TD&gt;&lt;TD&gt;10,533.33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Tuesday, August 25, 2020&lt;/TD&gt;&lt;TD&gt;11,860.00&lt;/TD&gt;&lt;TD&gt;10,658.33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Wednesday, August 26, 2020&lt;/TD&gt;&lt;TD&gt;11,820.00&lt;/TD&gt;&lt;TD&gt;10,785.00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Thursday, August 27, 2020&lt;/TD&gt;&lt;TD&gt;11,900.00&lt;/TD&gt;&lt;TD&gt;10,920.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you may see, monday's averages are wrong because takes data from previous 16 days. In addition, Dates Column (Fecha) Just have dates from monday to friday, there are no weekends on that table as I'm not using it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you once again for your support. I'll appreciate your help once again.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Aug 2020 15:11:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-Moving-Average-12/m-p/1333539#M23672</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-29T15:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Moving Average 12</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-Moving-Average-12/m-p/1333544#M23674</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your answer.&lt;/P&gt;&lt;P&gt;The column FECHA that contains dates just have dates from monday to friday, however in the calculation is taking weekends as well (I Think because I'm using DATESINPERIOD).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Aug 2020 15:14:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-Moving-Average-12/m-p/1333544#M23674</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-29T15:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Moving Average 12</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-Moving-Average-12/m-p/1333582#M23675</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;- Can you just use this?&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Rolling-Average/m-p/160720#M3" target="_blank"&gt;https://community.powerbi.com/t5/Quick-Measures-Gallery/Rolling-Average/m-p/160720#M3&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Aug 2020 15:47:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-Moving-Average-12/m-p/1333582#M23675</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-08-29T15:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Moving Average 12</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-Moving-Average-12/m-p/1334277#M23712</link>
      <description>&lt;LI-CODE lang="csharp"&gt;// For this stuff to work you need
// Calendar (a date table in the model).

[12D MA] =
var __maxVisibleDay = MAX( 'Calendar'[Date] )
var __countOfDaysToAvgOver = 12
var __datesToAvgOver =
    TOPN( __countOfDaysToAvgOver,
        // This table gets you the correct
        // number of days of the correct
        // type but you have to remember
        // that you might be too close
        // to the beginning of the
        // Calendar and in fact you'll
        // get fewer days than needed.
        CALCULATETABLE(
            VALUES( 'Calendar'[Date] ),
            'Calendar'[DayType] = "Weekday",
            'Calendar'[Date] &amp;lt;= __maxVisibleDay,
            ALL( 'Calendar' )
        ),
        'Calendar'[Date],
        DESC
    )
// This check is needed in case there
// are not enough days in the calendar
// (see the comment above).
var __thereAreEnoughDays =
    COUNTROWS( __datesToAvgOver )
        = __countOfDaysToAvgOver
return
if( __thereAreEnoughDays,
    CALCULATE(
        AVERAGEX(
            __datesToAvgOver,
            [Total Precios]
        ),
        // This directive is probably not
        // needed but only if 'Calendar'
        // is a proper Date table in
        // the model. But you can leave it
        // in as it works in any setting.
        ALL( 'Calendar' )
    )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 30 Aug 2020 17:49:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Problem-with-Moving-Average-12/m-p/1334277#M23712</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2020-08-30T17:49:04Z</dc:date>
    </item>
  </channel>
</rss>

