<?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 Calculating previous months sales using monthly data in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-previous-months-sales-using-monthly-data/m-p/3470640#M132511</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to build a formula into dax that calculates the previous months sales depending on which month is selected. For example in the screenshot below i want 'Sales (£) PM' to pull through July sales when August is selected in the Month filter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The data is at month level therefore a lot of the solutions posted on this forum aren't giving me the desired result, I have attached the calendar table below:&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;Any help would be massively appreicated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Matt.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Oct 2023 08:14:57 GMT</pubDate>
    <dc:creator>mes0012</dc:creator>
    <dc:date>2023-10-11T08:14:57Z</dc:date>
    <item>
      <title>Calculating previous months sales using monthly data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-previous-months-sales-using-monthly-data/m-p/3470640#M132511</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to build a formula into dax that calculates the previous months sales depending on which month is selected. For example in the screenshot below i want 'Sales (£) PM' to pull through July sales when August is selected in the Month filter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The data is at month level therefore a lot of the solutions posted on this forum aren't giving me the desired result, I have attached the calendar table below:&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;Any help would be massively appreicated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Matt.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 08:14:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-previous-months-sales-using-monthly-data/m-p/3470640#M132511</guid>
      <dc:creator>mes0012</dc:creator>
      <dc:date>2023-10-11T08:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating previous months sales using monthly data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-previous-months-sales-using-monthly-data/m-p/3470694#M132513</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Here is one way to do this:&lt;BR /&gt;Data:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Relation:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Dax:&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;LM =&lt;/SPAN&gt; &lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;_cmonth&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table (7)'&lt;/SPAN&gt;&lt;SPAN&gt;[YearMonth]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;max&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table (7)'&lt;/SPAN&gt;&lt;SPAN&gt;[Value]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;ALL&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table (7)'&lt;/SPAN&gt;&lt;SPAN&gt;[YearMonth]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;'Table (7)'&lt;/SPAN&gt;&lt;SPAN&gt;[YearMonth]&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;_cmonth&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;End result:&lt;BR /&gt;&lt;img /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
Here we remove YearMonth filter context and take the maximum value which is lower than current mont -&amp;gt; last month as context.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!&lt;BR /&gt;&lt;BR /&gt;My LinkedIn: &lt;A href="https://www.linkedin.com/in/n%C3%A4ttiahov-00001/" target="_blank"&gt;https://www.linkedin.com/in/n%C3%A4ttiahov-00001/&lt;/A&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 11 Oct 2023 08:45:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-previous-months-sales-using-monthly-data/m-p/3470694#M132513</guid>
      <dc:creator>ValtteriN</dc:creator>
      <dc:date>2023-10-11T08:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating previous months sales using monthly data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-previous-months-sales-using-monthly-data/m-p/3473224#M132636</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="343431" data-lia-user-login="ValtteriN" class="lia-mention lia-mention-user"&gt;ValtteriN&lt;/a&gt;, thanks for coming back on this.&lt;BR /&gt;&lt;BR /&gt;I've given the above suggestion a go but i can't get it to work.&amp;nbsp;I created a new table, summarised in the same way as in your suggestion above (Total Debit Balance is the original field name before i've renamed it in the visual):&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;However, when i build the measure i'm still getting blanks:&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Sales (£) PM = &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;_cmonth&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'AP - DR PM Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Y/MN Key]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;max&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'AP - DR PM Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Sales]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;ALL&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'AP - DR PM Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Y/MN Key]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;'AP - DR PM Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Y/MN Key]&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;_cmonth&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;Any chance you can see where i've gone wrong from those screenshots?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Matt.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2023 10:35:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-previous-months-sales-using-monthly-data/m-p/3473224#M132636</guid>
      <dc:creator>mes0012</dc:creator>
      <dc:date>2023-10-12T10:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating previous months sales using monthly data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-previous-months-sales-using-monthly-data/m-p/3475216#M132745</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="616409" data-lia-user-login="mes0012" class="lia-mention lia-mention-user"&gt;mes0012&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest you to create a DimDate table with continuous date in it and then try&amp;nbsp;&lt;A href="https://learn.microsoft.com/en-us/dax/previousmonth-function-dax" target="_self"&gt;PREVIOUSMONTH&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this reply still couldn't help you solve your issue, please share a sample file with us and show us a screenshot with the result you want.&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2023 09:13:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-previous-months-sales-using-monthly-data/m-p/3475216#M132745</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-13T09:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating previous months sales using monthly data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-previous-months-sales-using-monthly-data/m-p/3477951#M132919</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="616409" data-lia-user-login="mes0012" class="lia-mention lia-mention-user"&gt;mes0012&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Now that I revisited this I realized that there isn't anything preventing you from using previousmonth like&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp; suggested.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here is a bit better dax (if you don't want to use PREVIOUSMONTH for one reason or another):&lt;BR /&gt;&lt;BR /&gt;&lt;/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;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 16 Oct 2023 06:20:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-previous-months-sales-using-monthly-data/m-p/3477951#M132919</guid>
      <dc:creator>ValtteriN</dc:creator>
      <dc:date>2023-10-16T06:20:40Z</dc:date>
    </item>
  </channel>
</rss>

