<?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: Getting previous 3 months sales based on MTD Sales column in Desktop</title>
    <link>https://community.fabric.microsoft.com/t5/Desktop/Getting-previous-3-months-sales-based-on-MTD-Sales-column/m-p/2145254#M791103</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="307375" data-lia-user-login="smko" class="lia-mention lia-mention-user"&gt;smko&lt;/a&gt; , Takes sales base measure &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],eomonth(MAX('Date'[Date ]),0) ,-3,MONTH))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :&lt;A href="https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions" target="_blank"&gt;radacad&lt;/A&gt; &lt;A href="https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/" target="_blank"&gt;sqlbi&lt;/A&gt; &lt;A href="https://www.youtube.com/playlist?list=PLPaNVDMhUXGYLz-w8ERQOo3KYARs7GgG-" target="_blank"&gt;My Video Series&lt;/A&gt; Appreciate your Kudos. &lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Oct 2021 09:28:31 GMT</pubDate>
    <dc:creator>amitchandak</dc:creator>
    <dc:date>2021-10-20T09:28:31Z</dc:date>
    <item>
      <title>Getting previous 3 months sales based on MTD Sales column</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/Getting-previous-3-months-sales-based-on-MTD-Sales-column/m-p/2145159#M791080</link>
      <description>&lt;P&gt;Greetings people, I'm trying to get previous 3 months sales amount in current row, however due to the raw data is in Month-To-Date structure, MTD sales column will always reset to 0 at the beginning of the month, I find it hard find the correct solution. Here is how the raw data looks like, do note the date will not end at last day of the month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;MTD Sales&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Excepted Result&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;29/06/2021&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;100&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;30/07/2021&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;120&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;=0+0+100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;30/08/2021&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;200&lt;/TD&gt;&lt;TD&gt;220&lt;/TD&gt;&lt;TD&gt;=0+100+120&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;05/09/2021&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;50&lt;/TD&gt;&lt;TD&gt;420&lt;/TD&gt;&lt;TD&gt;=100+120+200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12/09/2021&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;70&lt;/TD&gt;&lt;TD&gt;420&lt;/TD&gt;&lt;TD&gt;=100+120+200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;29/09/2021&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;300&lt;/TD&gt;&lt;TD&gt;420&lt;/TD&gt;&lt;TD&gt;=100+120+200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;03/10/2021&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;30&lt;/TD&gt;&lt;TD&gt;620&lt;/TD&gt;&lt;TD&gt;=120+200+300&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the code but it will sum up all sales if there are multiple dates in a month. My idea is to get the last non blank date of each 3 previous month then maybe tweak the logic in my code. Appreciate anyone can provide better code and logic&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;Last3monthsSales = 
VAR Prev3months = STARTOFMONTH(DATEADD('Calendar'[Date],-3,MONTH))
VAR SOmonth = STARTOFMONTH('Calendar'[Date])
VAR Result = 
    CALCULATE(
        SUM(Sales[MTD Sales]),
        FILTER(
            ALL('Calendar'[Date]),
            'Calendar'[Date] &amp;lt; SOmonth &amp;amp;&amp;amp; 'Calendar'[Date] &amp;gt;= Prev3months
        )
    )
RETURN Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 09:11:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/Getting-previous-3-months-sales-based-on-MTD-Sales-column/m-p/2145159#M791080</guid>
      <dc:creator>smko</dc:creator>
      <dc:date>2021-10-20T09:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Getting previous 3 months sales based on MTD Sales column</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/Getting-previous-3-months-sales-based-on-MTD-Sales-column/m-p/2145254#M791103</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="307375" data-lia-user-login="smko" class="lia-mention lia-mention-user"&gt;smko&lt;/a&gt; , Takes sales base measure &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],eomonth(MAX('Date'[Date ]),0) ,-3,MONTH))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :&lt;A href="https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions" target="_blank"&gt;radacad&lt;/A&gt; &lt;A href="https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/" target="_blank"&gt;sqlbi&lt;/A&gt; &lt;A href="https://www.youtube.com/playlist?list=PLPaNVDMhUXGYLz-w8ERQOo3KYARs7GgG-" target="_blank"&gt;My Video Series&lt;/A&gt; Appreciate your Kudos. &lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 09:28:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/Getting-previous-3-months-sales-based-on-MTD-Sales-column/m-p/2145254#M791103</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2021-10-20T09:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Getting previous 3 months sales based on MTD Sales column</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/Getting-previous-3-months-sales-based-on-MTD-Sales-column/m-p/2145265#M791106</link>
      <description>&lt;P&gt;Hi there &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;, there is no Sales Amount column, only has MTD Sales column&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 09:49:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/Getting-previous-3-months-sales-based-on-MTD-Sales-column/m-p/2145265#M791106</guid>
      <dc:creator>smko</dc:creator>
      <dc:date>2021-10-20T09:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: Getting previous 3 months sales based on MTD Sales column</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/Getting-previous-3-months-sales-based-on-MTD-Sales-column/m-p/2149908#M792299</link>
      <description>&lt;P&gt;Please try to create a new column to calculate sales on the last date of each month.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;last_sales = 
var max_date = CALCULATE(MAX('Table'[Date]),ALLEXCEPT('Table','Table'[year_month]))
return IF('Table'[Date]=max_date,'Table'[ MTD Sales ])&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 08:10:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/Getting-previous-3-months-sales-based-on-MTD-Sales-column/m-p/2149908#M792299</guid>
      <dc:creator>V-lianl-msft</dc:creator>
      <dc:date>2021-10-22T08:10:14Z</dc:date>
    </item>
  </channel>
</rss>

