<?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: Plot average by legend category against time in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Plot-average-by-legend-category-against-time/m-p/2259265#M54584</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="338474" data-lia-user-login="oliverblane" class="lia-mention lia-mention-user"&gt;oliverblane&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;According to your description, here's my solution.&lt;/P&gt;
&lt;P&gt;Average is a measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Average = 
DIVIDE (
    [Cumulative LRN],
    CALCULATE (
        [Cumulative LRN],
        FILTER ( ALLSELECTED ( 'DateTable' ), MAX ( 'DateTable'[Date] ) )
    )
)
&lt;/LI-CODE&gt;
&lt;P&gt;Get the average value.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;DIV&gt;
&lt;P&gt;I attach my sample below for reference.&lt;/P&gt;
&lt;/DIV&gt;
&lt;DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;BR /&gt;Community Support Team _ kalyj&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Dec 2021 08:13:03 GMT</pubDate>
    <dc:creator>v-yanjiang-msft</dc:creator>
    <dc:date>2021-12-29T08:13:03Z</dc:date>
    <item>
      <title>Plot average by legend category against time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Plot-average-by-legend-category-against-time/m-p/2254089#M54385</link>
      <description>&lt;P&gt;I have a table that looks like the following:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I am currently plotting this data over time with a switch that allows the user to change whether the legend is Location Category, Content Provider, or Lot. An example of this is shown below:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if I was to click Lot on the slicer, then the plot would compare Lots instead.&lt;/P&gt;&lt;P&gt;However, I would like to modify this plot so that each unique category is calculated as an average per establishment. For example, when using Location Category as the legend, I would like to have each monthly value for Location A to be divided by 5 (since there are 5 establishments with Location = A), each monthly value for Location B to be divided by 3, and each monthly value for Location C to be divided by 2. The same should apply when using the Lot or Content Provider as the legend.&lt;/P&gt;&lt;P&gt;Here is a link to the PBIX file:&amp;nbsp;&lt;A href="https://meganexuslimited-my.sharepoint.com/:u:/g/personal/oliver_blane_meganexus_com/EdHNHYsYxGFOllte8yd7F1EB3CWyKW-lusM3Cl8U9y7pRQ?e=EOXhKV" target="_blank" rel="noopener"&gt;https://meganexuslimited-my.sharepoint.com/:u:/g/personal/oliver_blane_meganexus_com/EdHNHYsYxGFOllte8yd7F1EB3CWyKW-lusM3Cl8U9y7pRQ?e=EOXhKV&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for any help I might get on this!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 17:57:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Plot-average-by-legend-category-against-time/m-p/2254089#M54385</guid>
      <dc:creator>oliverblane</dc:creator>
      <dc:date>2021-12-23T17:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: Plot average by legend category against time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Plot-average-by-legend-category-against-time/m-p/2255128#M54414</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="338474" data-lia-user-login="oliverblane" class="lia-mention lia-mention-user"&gt;oliverblane&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The number of establishments in the current context is going to be&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;COUNTROWS(VALUES(Table[Establishment]))&lt;/LI-CODE&gt;
&lt;P&gt;So, you could have new measures that's a division of your existing measures by the above.&amp;nbsp; Something like:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Average Per Establishment =
VAR _Num = [Existing Measure]
VAR _Denom = COUNTROWS(VALUES(Table[Establishment]))
VAR _Result = DIVIDE(_Num, _Denom)
RETURN
    _Result&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 24 Dec 2021 10:34:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Plot-average-by-legend-category-against-time/m-p/2255128#M54414</guid>
      <dc:creator>PaulOlding</dc:creator>
      <dc:date>2021-12-24T10:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Plot average by legend category against time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Plot-average-by-legend-category-against-time/m-p/2255364#M54426</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="150936" data-lia-user-login="PaulOlding" class="lia-mention lia-mention-user"&gt;PaulOlding&lt;/a&gt;,&amp;nbsp;thank you for your reply.&lt;/P&gt;&lt;P&gt;Unfortunately this does not seem to solve the problem - I see the logic behind the measure, but I do not understand the result on the plot:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Thanks again for your help.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Dec 2021 14:10:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Plot-average-by-legend-category-against-time/m-p/2255364#M54426</guid>
      <dc:creator>oliverblane</dc:creator>
      <dc:date>2021-12-24T14:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: Plot average by legend category against time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Plot-average-by-legend-category-against-time/m-p/2259265#M54584</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="338474" data-lia-user-login="oliverblane" class="lia-mention lia-mention-user"&gt;oliverblane&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;According to your description, here's my solution.&lt;/P&gt;
&lt;P&gt;Average is a measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Average = 
DIVIDE (
    [Cumulative LRN],
    CALCULATE (
        [Cumulative LRN],
        FILTER ( ALLSELECTED ( 'DateTable' ), MAX ( 'DateTable'[Date] ) )
    )
)
&lt;/LI-CODE&gt;
&lt;P&gt;Get the average value.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;DIV&gt;
&lt;P&gt;I attach my sample below for reference.&lt;/P&gt;
&lt;/DIV&gt;
&lt;DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;BR /&gt;Community Support Team _ kalyj&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 08:13:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Plot-average-by-legend-category-against-time/m-p/2259265#M54584</guid>
      <dc:creator>v-yanjiang-msft</dc:creator>
      <dc:date>2021-12-29T08:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: Plot average by legend category against time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Plot-average-by-legend-category-against-time/m-p/2265167#M54844</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="334520" data-lia-user-login="v-yanjiang-msft" class="lia-mention lia-mention-user"&gt;v-yanjiang-msft&lt;/a&gt;, apologies for the late reply.&lt;/P&gt;&lt;P&gt;Thank you very much for this. I have a further question - what if I wanted to divide by the number of&amp;nbsp;&lt;STRONG&gt;unique&lt;/STRONG&gt; establishments, for example each monthly value for Location A to be divided by 4 instead of 5?&lt;BR /&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 09:31:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Plot-average-by-legend-category-against-time/m-p/2265167#M54844</guid>
      <dc:creator>oliverblane</dc:creator>
      <dc:date>2022-01-04T09:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Plot average by legend category against time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Plot-average-by-legend-category-against-time/m-p/2265194#M54847</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="338474" data-lia-user-login="oliverblane" class="lia-mention lia-mention-user"&gt;oliverblane&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;According to your description, you can modify the Cumulative LRN formula like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Cumulative LRN = 
var MaxDate = MAX(DateTable[Date])
return SWITCH(
    TRUE(),
    SELECTEDVALUE(LegendCategories[Field]) = "Location",
    CALCULATE(
        DISTINCTCOUNT( 'SubTable'[Establishment] ),
        KEEPFILTERS( DateTable[Date] &amp;lt;= MaxDate ),
        ALLSELECTED( DateTable ),
        USERELATIONSHIP(LegendCategories[Category], 'SubTable'[Location Category])
    ),
    SELECTEDVALUE(LegendCategories[Field]) = "Content Provider",
    CALCULATE(
        DISTINCTCOUNT( 'SubTable'[Establishment] ),
        KEEPFILTERS( DateTable[Date] &amp;lt;= MaxDate ),
        ALLSELECTED( DateTable ),
        USERELATIONSHIP(LegendCategories[Category], 'SubTable'[Content Provider])
    ),
    SELECTEDVALUE(LegendCategories[Field]) = "Lot",
    CALCULATE(
        DISTINCTCOUNT( 'SubTable'[Establishment] ),
        KEEPFILTERS( DateTable[Date] &amp;lt;= MaxDate ),
        ALLSELECTED( DateTable ),
        USERELATIONSHIP(LegendCategories[Category], 'SubTable'[Lot]
    )
))&lt;/LI-CODE&gt;
&lt;P&gt;I modify "&lt;SPAN style="font-family: inherit;"&gt;DISTINCTCOUNT&lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;( &lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;'SubTable'[LRN]&lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt; )" with "&lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;DISTINCTCOUNT&lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;( &lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;'SubTable'[Establishment]&lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt; )"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Community Support Team _ kalyj&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 09:47:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Plot-average-by-legend-category-against-time/m-p/2265194#M54847</guid>
      <dc:creator>v-yanjiang-msft</dc:creator>
      <dc:date>2022-01-04T09:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: Plot average by legend category against time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Plot-average-by-legend-category-against-time/m-p/2265226#M54853</link>
      <description>&lt;P&gt;Thanks again&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="334520" data-lia-user-login="v-yanjiang-msft" class="lia-mention lia-mention-user"&gt;v-yanjiang-msft&lt;/a&gt;,&amp;nbsp;this seems to work! I appreciate all your help.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 10:14:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Plot-average-by-legend-category-against-time/m-p/2265226#M54853</guid>
      <dc:creator>oliverblane</dc:creator>
      <dc:date>2022-01-04T10:14:48Z</dc:date>
    </item>
  </channel>
</rss>

