<?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: Line Chart Legend Rolling Average in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Line-Chart-Legend-Rolling-Average/m-p/4216599#M167121</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;One of ways is to have dimension tables for date and company, and create one to many relationship to the fact table, that looks something like below.&lt;/P&gt;
&lt;P&gt;Please check the below picture and the attached pbix file.&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;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/window-function-dax?wt.mc_id=DP-MVP-5004989" target="_blank"&gt;WINDOW function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;sales 6 months rolling avg: = 
VAR _t =
    WINDOW (
        -5,
        REL,
        0,
        REL,
        ALL ( calendar_dim[Year-Month], calendar_dim[Year-Month sort] ),
        ORDERBY ( calendar_dim[Year-Month sort], ASC )
    )
RETURN
    IF (
        SUM ( sales_fact[value] ),
        AVERAGEX ( _t, CALCULATE ( SUM ( sales_fact[value] ) ) )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Oct 2024 03:43:10 GMT</pubDate>
    <dc:creator>Jihwan_Kim</dc:creator>
    <dc:date>2024-10-04T03:43:10Z</dc:date>
    <item>
      <title>Line Chart Legend Rolling Average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Line-Chart-Legend-Rolling-Average/m-p/4215677#M167105</link>
      <description>&lt;P&gt;Have this table of data in power billing with thus measure. Issue I'm running into is when I create a line chart the rolling average is calculated correctly (dates on x axis rolling on your axis). If I add [Name] to legend the names A and B show up on the legend but there remains only 1 line with the total rolling average and not two lines with rolling average for both A and B. Any help would be appreciated&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;RollingMean6Months =&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR CurrentDate = MAX('Charge'[Date])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR SixMonthsAgo = EDATE(CurrentDate, -6)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RETURN&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; AVERAGEX(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FILTER(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ALL('Charge'),&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Charge'[Date] &amp;lt;= CurrentDate &amp;amp;&amp;amp; 'Charge'[Date] &amp;gt; SixMonthsAgo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ),&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Charge'[Value]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &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;</description>
      <pubDate>Thu, 03 Oct 2024 18:16:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Line-Chart-Legend-Rolling-Average/m-p/4215677#M167105</guid>
      <dc:creator>vjr37</dc:creator>
      <dc:date>2024-10-03T18:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Line Chart Legend Rolling Average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Line-Chart-Legend-Rolling-Average/m-p/4216478#M167119</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="633485" data-lia-user-login="vjr37" class="lia-mention lia-mention-user"&gt;vjr37&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to add [Name] in Legend and display two lines based on Name, I suggest you to update code as below.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;RollingMean6Months = 
VAR CurrentDate =
    MAX ( 'Charge'[Date] )
VAR SixMonthsAgo =
    EDATE ( CurrentDate, -6 )
RETURN
    AVERAGEX (
        FILTER (
            ALL( 'Charge'),
            Charge[Name] = MAX(Charge[Name]) &amp;amp;&amp;amp;
            'Charge'[Date] &amp;lt;= CurrentDate
                &amp;amp;&amp;amp; 'Charge'[Date] &amp;gt; SixMonthsAgo
        ),
        'Charge'[Value]
    )&lt;/LI-CODE&gt;
&lt;P&gt;Result is as below.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 02:42:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Line-Chart-Legend-Rolling-Average/m-p/4216478#M167119</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-10-04T02:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Line Chart Legend Rolling Average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Line-Chart-Legend-Rolling-Average/m-p/4216599#M167121</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;One of ways is to have dimension tables for date and company, and create one to many relationship to the fact table, that looks something like below.&lt;/P&gt;
&lt;P&gt;Please check the below picture and the attached pbix file.&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;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/window-function-dax?wt.mc_id=DP-MVP-5004989" target="_blank"&gt;WINDOW function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;sales 6 months rolling avg: = 
VAR _t =
    WINDOW (
        -5,
        REL,
        0,
        REL,
        ALL ( calendar_dim[Year-Month], calendar_dim[Year-Month sort] ),
        ORDERBY ( calendar_dim[Year-Month sort], ASC )
    )
RETURN
    IF (
        SUM ( sales_fact[value] ),
        AVERAGEX ( _t, CALCULATE ( SUM ( sales_fact[value] ) ) )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 03:43:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Line-Chart-Legend-Rolling-Average/m-p/4216599#M167121</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2024-10-04T03:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Line Chart Legend Rolling Average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Line-Chart-Legend-Rolling-Average/m-p/4218062#M167146</link>
      <description>&lt;P&gt;Thanks! This worked!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 12:13:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Line-Chart-Legend-Rolling-Average/m-p/4218062#M167146</guid>
      <dc:creator>vjr37</dc:creator>
      <dc:date>2024-10-04T12:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Line Chart Legend Rolling Average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Line-Chart-Legend-Rolling-Average/m-p/4218067#M167147</link>
      <description>&lt;P&gt;This also worked as well. I'd say this method follows appropriate standard practice too. Thanks for the help&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 12:15:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Line-Chart-Legend-Rolling-Average/m-p/4218067#M167147</guid>
      <dc:creator>vjr37</dc:creator>
      <dc:date>2024-10-04T12:15:53Z</dc:date>
    </item>
  </channel>
</rss>

