<?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 compare sales and percentage changes in sales in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/compare-sales-and-percentage-changes-in-sales/m-p/4276500#M169677</link>
    <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please refer the below data and refer the below questions&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Required DAX measuere for below questions&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1. Compare sales in previous months&lt;/P&gt;&lt;P&gt;2.how much percentage increased/decreased month on month basis on the sales&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;Thanks&lt;/P&gt;</description>
    <pubDate>Sat, 09 Nov 2024 10:36:29 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-11-09T10:36:29Z</dc:date>
    <item>
      <title>compare sales and percentage changes in sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/compare-sales-and-percentage-changes-in-sales/m-p/4276500#M169677</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please refer the below data and refer the below questions&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Required DAX measuere for below questions&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1. Compare sales in previous months&lt;/P&gt;&lt;P&gt;2.how much percentage increased/decreased month on month basis on the sales&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;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 09 Nov 2024 10:36:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/compare-sales-and-percentage-changes-in-sales/m-p/4276500#M169677</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-09T10:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: compare sales and percentage changes in sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/compare-sales-and-percentage-changes-in-sales/m-p/4276790#M169694</link>
      <description>&lt;P&gt;hello&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please check if this accomodate your need.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. create measure for your 1st query with following DAX&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;Query &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt; =&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;_Month&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;SELECTEDVALUE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Month]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Return&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Sales]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;2. create measure for your 2st query with following DAX&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;Query &lt;/SPAN&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt; =&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;_PreviousMonth&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Query 1]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Month]&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Month]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;_CurrentMonth&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Query 1]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Month]&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'&lt;/SPAN&gt;&lt;SPAN&gt;[Month]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Return&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DIVIDE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;_CurrentMonth&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;_PreviousMonth&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Hope this will help.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 10 Nov 2024 01:38:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/compare-sales-and-percentage-changes-in-sales/m-p/4276790#M169694</guid>
      <dc:creator>Irwan</dc:creator>
      <dc:date>2024-11-10T01:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: compare sales and percentage changes in sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/compare-sales-and-percentage-changes-in-sales/m-p/4276905#M169698</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am not sure if I understood your question correctly, but I tried to create a sample pbix file 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;LI-CODE lang="markup"&gt;Sales: = 
SUM( sales[sales] )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/offset-function-dax?wt.mc_id=DP-MVP-5004989" target="_blank"&gt;OFFSET 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;Previous month sales: = 
CALCULATE (
    [Sales:],
    OFFSET (
        -1,
        ALL ( 'calendar'[Month-Year], 'calendar'[Year-Month sort] ),
        ORDERBY ( 'calendar'[Year-Month sort], ASC )
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Nov 2024 05:54:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/compare-sales-and-percentage-changes-in-sales/m-p/4276905#M169698</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2024-11-10T05:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: compare sales and percentage changes in sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/compare-sales-and-percentage-changes-in-sales/m-p/4278058#M169754</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To help you with the DAX measures for comparing sales in previous months and calculating the percentage increase/decrease in sales month-over-month, I'll break down each question and provide the corresponding DAX expressions.&lt;/P&gt;&lt;H3&gt;1. &lt;STRONG&gt;Compare Sales in Previous Months&lt;/STRONG&gt;&lt;/H3&gt;&lt;P&gt;To compare the sales in the current month with the previous month, we need to calculate the total sales for both the current month and the previous month.&lt;/P&gt;&lt;P&gt;Assuming you have a &lt;STRONG&gt;Sales&lt;/STRONG&gt; table with a &lt;STRONG&gt;SalesAmount&lt;/STRONG&gt; column, and the &lt;STRONG&gt;Date&lt;/STRONG&gt; table is linked properly to your &lt;STRONG&gt;Sales&lt;/STRONG&gt; table, you can use the following measure to calculate sales for the previous month:&lt;/P&gt;&lt;H4&gt;&lt;STRONG&gt;Sales in Previous Month&lt;/STRONG&gt;&lt;/H4&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DAX
Sales Previous Month = 
CALCULATE(
    SUM(Sales[SalesAmount]),
    PREVIOUSMONTH(Dim_Calendar[Date])
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;This measure uses the PREVIOUSMONTH function to shift the date context to the previous month and then sums the sales for that period.&lt;/LI&gt;&lt;/UL&gt;&lt;H4&gt;&lt;STRONG&gt;Sales in Current Month&lt;/STRONG&gt;&lt;/H4&gt;&lt;P&gt;If you want to show the sales for the current month as well (if not already available), you can simply use this measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DAX
Sales Current Month = 
SUM(Sales[SalesAmount])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;2. &lt;STRONG&gt;Percentage Increase/Decrease in Sales Month on Month&lt;/STRONG&gt;&lt;/H3&gt;&lt;P&gt;To calculate the percentage change in sales month-over-month (MoM), you can use the following measure:&lt;/P&gt;&lt;H4&gt;&lt;STRONG&gt;Percentage Change in Sales&lt;/STRONG&gt;&lt;/H4&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DAX
Percentage Change in Sales = 
VAR CurrentSales = SUM(Sales[SalesAmount])
VAR PreviousSales = 
    CALCULATE(
        SUM(Sales[SalesAmount]),
        PREVIOUSMONTH(Dim_Calendar[Date])
    )
RETURN 
    IF(
        NOT(ISBLANK(PreviousSales)),
        (CurrentSales - PreviousSales) / PreviousSales,
        BLANK()
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Explanation&lt;/STRONG&gt;:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;CurrentSales: This variable holds the sales for the current month.&lt;/LI&gt;&lt;LI&gt;PreviousSales: This variable calculates the sales for the previous month using the PREVIOUSMONTH function.&lt;/LI&gt;&lt;LI&gt;The formula (CurrentSales - PreviousSales) / PreviousSales gives the percentage change.&lt;/LI&gt;&lt;LI&gt;The IF condition ensures that the measure doesn't return a value when the previous month’s sales are blank (e.g., for the first month in the dataset).&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;Summary of Measures&lt;/H3&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Sales in Previous Month&lt;/STRONG&gt;: Sales Previous Month = CALCULATE(SUM(Sales[SalesAmount]), PREVIOUSMONTH(Dim_Calendar[Date]))&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Sales in Current Month&lt;/STRONG&gt;: Sales Current Month = SUM(Sales[SalesAmount])&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Percentage Change in Sales&lt;/STRONG&gt;:&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DAX
Percentage Change in Sales = 
VAR CurrentSales = SUM(Sales[SalesAmount])
VAR PreviousSales = 
    CALCULATE(SUM(Sales[SalesAmount]), PREVIOUSMONTH(Dim_Calendar[Date]))
RETURN 
    IF(NOT(ISBLANK(PreviousSales)), (CurrentSales - PreviousSales) / PreviousSales, BLANK())​&lt;/LI-CODE&gt;&lt;P&gt;This should provide you with a way to compare sales across months and calculate the percentage change month on month. Let me know if you need any further adjustments!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Did I answer your question? Mark my post as a solution, this will help others!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If my response(s) assisted you in any way, don't forget to drop me a "&lt;STRONG&gt;Kudos&lt;/STRONG&gt;" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;BR /&gt;Poojara&lt;BR /&gt;Data Analyst | MSBI Developer | Power BI Consultant&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2024 09:49:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/compare-sales-and-percentage-changes-in-sales/m-p/4278058#M169754</guid>
      <dc:creator>Poojara_D12</dc:creator>
      <dc:date>2024-11-11T09:49:08Z</dc:date>
    </item>
  </channel>
</rss>

