<?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 COLUMN Rolling 20week Sales in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATING-COLUMN-Rolling-20week-Sales/m-p/2434989#M64950</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="92006" data-lia-user-login="joshua1990" class="lia-mention lia-mention-user"&gt;joshua1990&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try the following methods.&amp;nbsp;I simulated some data briefly and hope it will meet your requirements.&lt;/P&gt;
&lt;P&gt;Column:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Year-Week = YEAR([Date])&amp;amp;"-"&amp;amp;WEEKNUM([Date],2)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Rolling 20 week sales = 
VAR N1 =
    SUMMARIZE (
        FILTER ( Transactional, [Year-Week] &amp;lt;= MAX ( Transactional[Year-Week] ) ),
        [Date],
        "Sum",
            CALCULATE (
                SUM ( Transactional[Sales] ),
                FILTER ( Transactional, [Article] = EARLIER ( Dimensional[Article] ) )
            )
    )
VAR N2 =
    TOPN ( 20, N1, [Date], DESC )
RETURN
    SUMX ( N2, [Sum] )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Please see the attachment for details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Community Support Team _Charlotte&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
    <pubDate>Mon, 04 Apr 2022 08:36:38 GMT</pubDate>
    <dc:creator>v-zhangti</dc:creator>
    <dc:date>2022-04-04T08:36:38Z</dc:date>
    <item>
      <title>CALCULATING COLUMN Rolling 20week Sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATING-COLUMN-Rolling-20week-Sales/m-p/2429098#M64609</link>
      <description>&lt;P&gt;Hi experts!&lt;/P&gt;&lt;P&gt;I have a Dimensional Table that contains all Articles for each department:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Article&lt;/TD&gt;&lt;TD&gt;Department&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;EDFG&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I have a transactional table:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Year-Week&lt;/TD&gt;&lt;TD&gt;Article&lt;/TD&gt;&lt;TD&gt;Sales&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2022-01&lt;/TD&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2022-02&lt;/TD&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;TD&gt;600&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2022-03&lt;/TD&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I would like to add a calculated column into the dimensional table that shows me all Sales for each Article for the past 20 weeks.&lt;/P&gt;&lt;P&gt;I now, I general we would do that as a simple Dax Measure in a matrix visual.&lt;/P&gt;&lt;P&gt;But here is the ask as a calculated column. How would you do that?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 09:34:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATING-COLUMN-Rolling-20week-Sales/m-p/2429098#M64609</guid>
      <dc:creator>joshua1990</dc:creator>
      <dc:date>2022-03-31T09:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: CALCULATING COLUMN Rolling 20week Sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATING-COLUMN-Rolling-20week-Sales/m-p/2429278#M64616</link>
      <description>&lt;P&gt;Assuming that you have a date table with a start of week column, you could add a column as&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Rolling 20 week sales = 
var startDate = LOOKUPVALUE('Date'[start of week], 'Date'[Date], TODAY())
return CALCULATE( SUMX( RELATEDTABLE( 'Transactions'), 'Transactions'[Sales]),
'Date'[Date] &amp;gt;= startDate
)&lt;/LI-CODE&gt;&lt;P&gt;This would be recalculated whenever the data is refreshed&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 11:11:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATING-COLUMN-Rolling-20week-Sales/m-p/2429278#M64616</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2022-03-31T11:11:10Z</dc:date>
    </item>
    <item>
      <title>Re: CALCULATING COLUMN Rolling 20week Sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATING-COLUMN-Rolling-20week-Sales/m-p/2434989#M64950</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="92006" data-lia-user-login="joshua1990" class="lia-mention lia-mention-user"&gt;joshua1990&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try the following methods.&amp;nbsp;I simulated some data briefly and hope it will meet your requirements.&lt;/P&gt;
&lt;P&gt;Column:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Year-Week = YEAR([Date])&amp;amp;"-"&amp;amp;WEEKNUM([Date],2)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Rolling 20 week sales = 
VAR N1 =
    SUMMARIZE (
        FILTER ( Transactional, [Year-Week] &amp;lt;= MAX ( Transactional[Year-Week] ) ),
        [Date],
        "Sum",
            CALCULATE (
                SUM ( Transactional[Sales] ),
                FILTER ( Transactional, [Article] = EARLIER ( Dimensional[Article] ) )
            )
    )
VAR N2 =
    TOPN ( 20, N1, [Date], DESC )
RETURN
    SUMX ( N2, [Sum] )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Please see the attachment for details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Community Support Team _Charlotte&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 08:36:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/CALCULATING-COLUMN-Rolling-20week-Sales/m-p/2434989#M64950</guid>
      <dc:creator>v-zhangti</dc:creator>
      <dc:date>2022-04-04T08:36:38Z</dc:date>
    </item>
  </channel>
</rss>

