<?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: Calculating avg based on number of months in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-avg-based-on-number-of-months/m-p/2190223#M51177</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313203" data-lia-user-login="nidhijo" class="lia-mention lia-mention-user"&gt;nidhijo&lt;/a&gt;&amp;nbsp;To remove the previous months with no data, you need your measures that are returning data in those months to return BLANK instead.&lt;/P&gt;</description>
    <pubDate>Mon, 15 Nov 2021 11:58:07 GMT</pubDate>
    <dc:creator>Greg_Deckler</dc:creator>
    <dc:date>2021-11-15T11:58:07Z</dc:date>
    <item>
      <title>Calculating avg based on number of months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-avg-based-on-number-of-months/m-p/2188746#M51112</link>
      <description>&lt;P&gt;Hi all!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have data that contains quantity ordered and has the dates assosicated with the orders, what I want to calculate is an average of the quantity ordered calculated by number of months. For eg: for the time period june 2019-june 2020 the calculation would be =total number of orders/13 (number of months)&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am doing this to be able to plot an avg line in a line and column chart that shows the quanity ordered by months:&amp;nbsp;&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;The avg should be indicated by the dark blue line but clearly it is wrong. Also, how can I remove the previous months that have no orders for this particular location, every location has different data...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also thought of calculating the number of months from the first month ordered till current month, but I'm struggling to do that as well..&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry if this is too complicated but any help would be greatly appreciated!!! I'm relatively new to power BI and I've been struggling with this report for the past few days.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank 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;</description>
      <pubDate>Sun, 14 Nov 2021 05:40:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-avg-based-on-number-of-months/m-p/2188746#M51112</guid>
      <dc:creator>nidhijo</dc:creator>
      <dc:date>2021-11-14T05:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating avg based on number of months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-avg-based-on-number-of-months/m-p/2188791#M51114</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313203" data-lia-user-login="nidhijo" class="lia-mention lia-mention-user"&gt;nidhijo&lt;/a&gt;&amp;nbsp;Can't you just use the Analytics pane's Average feature? Otherwise it is a measure aggregation problem.&amp;nbsp;This looks like a measure aggregation problem. See my blog article about that here: &lt;A href="https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;The pattern is: &lt;BR /&gt;MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])&lt;BR /&gt;MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])&lt;BR /&gt;AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])&lt;BR /&gt;etc.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Nov 2021 10:30:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-avg-based-on-number-of-months/m-p/2188791#M51114</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-11-14T10:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating avg based on number of months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-avg-based-on-number-of-months/m-p/2189294#M51146</link>
      <description>&lt;P&gt;I can't use the analytics pane as it is only for the line visual, if I convert this to line visual it does not show me the distrubution for each month which I would like to see. Thanks for the link I'll check out your blog. Also, do you know how I could remove the previous months with no data from my visual?&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 03:31:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-avg-based-on-number-of-months/m-p/2189294#M51146</guid>
      <dc:creator>nidhijo</dc:creator>
      <dc:date>2021-11-15T03:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating avg based on number of months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-avg-based-on-number-of-months/m-p/2190223#M51177</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313203" data-lia-user-login="nidhijo" class="lia-mention lia-mention-user"&gt;nidhijo&lt;/a&gt;&amp;nbsp;To remove the previous months with no data, you need your measures that are returning data in those months to return BLANK instead.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 11:58:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-avg-based-on-number-of-months/m-p/2190223#M51177</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-11-15T11:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating avg based on number of months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-avg-based-on-number-of-months/m-p/2193957#M51346</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313203" data-lia-user-login="nidhijo" class="lia-mention lia-mention-user"&gt;nidhijo&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depend on you chart, I create some data.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;AVARAGE Quantity =
VAR _total =
    SUMX( ALL( 'Table' ), [Orders] ) 
// If you have condition to calculate the number of quantity order, you can use SUMX(FILTER(ALL('Table'),conditions),[Orders])
VAR _numOfmonth =
    COUNTROWS(
        FILTER(
            SUMMARIZE( ALL( 'Table' ), 'Table'[Date], "sum", SUM( 'Table'[Orders] ) ),
            [sum] &amp;gt; 0
        )
    )
RETURN
    _total / _numOfmonth
//  If you do not want to display the blank months , try following
// IF(ISBLANK([Quantity orders]),BLANK(),_total/_numOfmonth)
&lt;/LI-CODE&gt;
&lt;P&gt;The result:&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;OR&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;I put my pbix file in the attachment and you can refer, if I misunderstood you, please let me know.&lt;/P&gt;
&lt;P class="lia-align-left"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Community Support Team _ chenwu zhu&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 08:54:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-avg-based-on-number-of-months/m-p/2193957#M51346</guid>
      <dc:creator>v-chenwuz-msft</dc:creator>
      <dc:date>2021-11-17T08:54:08Z</dc:date>
    </item>
  </channel>
</rss>

