<?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 Calculate Previous Month Total When Two Dates Are Equal in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Total-When-Two-Dates-Are-Equal/m-p/3337390#M125176</link>
    <description>&lt;P&gt;I currently have 3 tables - sales, customer, date. For the date table, I am using the [Month End] column&amp;nbsp;(&lt;U&gt;always the last day of the month&lt;/U&gt;) on the 'Date Table' to filter the Sales table (see the screenshot below).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have written a measure below to calcualte the total mobile sales when the transaction date equals the posting date:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Current Month Mobile Sales =&amp;nbsp;&lt;BR /&gt;Calculate(&lt;BR /&gt;Sum(Sales[Total Amount],&lt;BR /&gt;Customer[Customer_Type] = "Mobile",&lt;BR /&gt;Sales[Transaction Date] =&amp;nbsp;&lt;SPAN&gt;Sales[Posting Date]&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;How can I get the "previous month&amp;nbsp;Mobile Sales"? I wrote the DAX below:&lt;/P&gt;&lt;P&gt;Calculate(&lt;BR /&gt;[Current Month Mobile Sales],&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DATEADD&lt;/SPAN&gt;&lt;SPAN&gt;('Date Table'[Month End], -&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;, MONTH)&lt;BR /&gt;&lt;/SPAN&gt;)&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it only works when there are 31 days in a month. How should I fix it to get the correct "previous month&amp;nbsp;Mobile Sales" when filtering by the [Month End] column?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jul 2023 22:39:09 GMT</pubDate>
    <dc:creator>InfiniteSheldon</dc:creator>
    <dc:date>2023-07-18T22:39:09Z</dc:date>
    <item>
      <title>Calculate Previous Month Total When Two Dates Are Equal</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Total-When-Two-Dates-Are-Equal/m-p/3337390#M125176</link>
      <description>&lt;P&gt;I currently have 3 tables - sales, customer, date. For the date table, I am using the [Month End] column&amp;nbsp;(&lt;U&gt;always the last day of the month&lt;/U&gt;) on the 'Date Table' to filter the Sales table (see the screenshot below).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have written a measure below to calcualte the total mobile sales when the transaction date equals the posting date:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Current Month Mobile Sales =&amp;nbsp;&lt;BR /&gt;Calculate(&lt;BR /&gt;Sum(Sales[Total Amount],&lt;BR /&gt;Customer[Customer_Type] = "Mobile",&lt;BR /&gt;Sales[Transaction Date] =&amp;nbsp;&lt;SPAN&gt;Sales[Posting Date]&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;How can I get the "previous month&amp;nbsp;Mobile Sales"? I wrote the DAX below:&lt;/P&gt;&lt;P&gt;Calculate(&lt;BR /&gt;[Current Month Mobile Sales],&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DATEADD&lt;/SPAN&gt;&lt;SPAN&gt;('Date Table'[Month End], -&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;, MONTH)&lt;BR /&gt;&lt;/SPAN&gt;)&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it only works when there are 31 days in a month. How should I fix it to get the correct "previous month&amp;nbsp;Mobile Sales" when filtering by the [Month End] column?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2023 22:39:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Total-When-Two-Dates-Are-Equal/m-p/3337390#M125176</guid>
      <dc:creator>InfiniteSheldon</dc:creator>
      <dc:date>2023-07-18T22:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Previous Month Total When Two Dates Are Equal</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Total-When-Two-Dates-Are-Equal/m-p/3338169#M125214</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="439303" data-lia-user-login="InfiniteSheldon" class="lia-mention lia-mention-user"&gt;InfiniteSheldon&lt;/a&gt;&amp;nbsp;did you try DAX function TOTALMTD? Hope this help&lt;/P&gt;&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/totalmtd-function-dax?WT.mc_id=DP-MVP-4025372" target="_self"&gt;https://learn.microsoft.com/en-us/dax/totalmtd-function-dax?WT.mc_id=DP-MVP-4025372&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 08:53:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Total-When-Two-Dates-Are-Equal/m-p/3338169#M125214</guid>
      <dc:creator>some_bih</dc:creator>
      <dc:date>2023-07-19T08:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Previous Month Total When Two Dates Are Equal</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Total-When-Two-Dates-Are-Equal/m-p/3339031#M125294</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="555045" data-lia-user-login="some_bih" class="lia-mention lia-mention-user"&gt;some_bih&lt;/a&gt;, could you please be more specific? I am not sure how&amp;nbsp;&lt;SPAN&gt;TOTALMTD is going to help calculate previous month total when two dates are the same.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 16:03:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Total-When-Two-Dates-Are-Equal/m-p/3339031#M125294</guid>
      <dc:creator>InfiniteSheldon</dc:creator>
      <dc:date>2023-07-19T16:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Previous Month Total When Two Dates Are Equal</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Total-When-Two-Dates-Are-Equal/m-p/3339294#M125310</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="439303" data-lia-user-login="InfiniteSheldon" class="lia-mention lia-mention-user"&gt;InfiniteSheldon&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apply as measure X=TOTALMTD(&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[Current Month Mobile Sales], 'Your Date table date column key')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Check result. Hope this help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 17:55:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Total-When-Two-Dates-Are-Equal/m-p/3339294#M125310</guid>
      <dc:creator>some_bih</dc:creator>
      <dc:date>2023-07-19T17:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Previous Month Total When Two Dates Are Equal</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Total-When-Two-Dates-Are-Equal/m-p/3339377#M125313</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="555045" data-lia-user-login="some_bih" class="lia-mention lia-mention-user"&gt;some_bih&lt;/a&gt;, I don't think that's the solution. However, I figured it out myself using&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;PREVIOUSMONTH rather than&amp;nbsp;DATEADD('Date Table'[Month End], -1, MONTH). Thanks anyway for your help!&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 19 Jul 2023 19:06:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Previous-Month-Total-When-Two-Dates-Are-Equal/m-p/3339377#M125313</guid>
      <dc:creator>InfiniteSheldon</dc:creator>
      <dc:date>2023-07-19T19:06:23Z</dc:date>
    </item>
  </channel>
</rss>

