<?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 last month sales without any date table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2166428#M50210</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your message.&lt;/P&gt;
&lt;P&gt;Please try to fix the measure like below.&lt;/P&gt;
&lt;P&gt;I think RIGHT function and LEFT function are missplaced.&lt;/P&gt;
&lt;P&gt;Mine is starting with month number, but yours is starting with year number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Previous month sales : =&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;EM&gt;VAR yearnumber =&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;INT ( LEFT ( SELECTEDVALUE ( Data[Sort month year] ), 4 ) )&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;VAR monthnumber =&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;INT ( RIGHT ( SELECTEDVALUE ( 'Data'[Sort month year] ), 2 ) )&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;VAR currentyearmonthnumber = yearnumber * 12 + monthnumber&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;RETURN&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;CALCULATE (&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;[Amount Sum],&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;FILTER (&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ALL ( Data ),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;CALCULATE (&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;INT ( LEFT ( SELECTEDVALUE ( Data[Sort month year] ), 4 ) ) * 12&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;+ INT ( RIGHT ( SELECTEDVALUE ( Data[Sort month year] ), 2 ) )&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;) = currentyearmonthnumber - 1&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Nov 2021 14:12:15 GMT</pubDate>
    <dc:creator>Jihwan_Kim</dc:creator>
    <dc:date>2021-11-01T14:12:15Z</dc:date>
    <item>
      <title>Getting last month sales without any date table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2159245#M49920</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cant use a date table for various reasons but I cant make it work how to get previous month sales without the date time intelligence.&lt;/P&gt;&lt;P&gt;What i want is when the user selects 2019 and month 1 he sees the sales of 2018 and month 12 next to it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Whats the replacement for Calculate(SUM(sales), dateadd(date, month, -1) if the date table isnt there?&lt;/P&gt;&lt;P&gt;I have only one table with my sales and companies.&lt;/P&gt;&lt;P&gt;I tried using calculate(SUM(table (sales), filter(table(monthyear)= selectedvalue(monthyear) -1 but this doesnt show me nothing , just 0s. Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 21:36:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2159245#M49920</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-27T21:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: Getting last month sales without any date table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2159281#M49922</link>
      <description>&lt;P&gt;You need something to remove or replace the current month filter context.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try something this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;PrevMonthSum =
VAR SelectedMonthYear = SELECTEDVALUE ( table1[monthyear] )
RETURN
    CALCULATE ( SUM ( table1[sales] ), table1[monthyear] = SelectedMonthYear - 1 )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;or this&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SumPrevMonth = 
CALCULATE (
    SUM ( table1[sales] ),
    FILTER (
        ALL ( table1[monthyear] ),
        table1[monthyear] = SELECTEDVALUE ( table1[monthyear] ) - 1
    )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 27 Oct 2021 21:54:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2159281#M49922</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2021-10-27T21:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Getting last month sales without any date table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2159683#M49934</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;If you have a column for soring a monthyear column, it will be much easier to author DAX measure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume you do not have a column for sorting a monthyear column, and monthyear column is a text type.&lt;/P&gt;
&lt;P&gt;In that case, please check the 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;DIV&gt;
&lt;DIV&gt;&lt;STRONG&gt;&lt;EM&gt;Sales total : = &lt;/EM&gt;&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;SUM('Table'[sales] )&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;STRONG&gt;&lt;EM&gt;Previous month sales : = &lt;/EM&gt;&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;VAR yearnumber =&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;INT ( RIGHT ( SELECTEDVALUE ( 'Table'[monthyear] ), 4 ) )&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;VAR monthnumber =&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;INT ( LEFT ( SELECTEDVALUE ( 'Table'[monthyear] ), 2 ) )&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;VAR currentyearmonthnumber = yearnumber * 12 + monthnumber&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;RETURN&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;CALCULATE (&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;[Sales total :],&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;FILTER (&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;ALL ( 'Table' ),&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;CALCULATE (&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;INT ( RIGHT ( SELECTEDVALUE ( 'Table'[monthyear] ), 4 ) ) * 12&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt; + INT ( LEFT ( SELECTEDVALUE ( 'Table'[monthyear] ), 2 ) ) = currentyearmonthnumber - 1&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt; )&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt; )&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt; )&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 03:30:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2159683#M49934</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2021-10-28T03:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Getting last month sales without any date table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2160382#M49944</link>
      <description>&lt;P&gt;Thanks to both of you! I tried both but the problem was that the first solution&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="291628" data-lia-user-login="Jihwan_Kim" class="lia-mention lia-mention-user"&gt;Jihwan_Kim&lt;/a&gt;&amp;nbsp; doesnt give me any values, I guess its because of the ALL (table) as I have to show also other entities in the table. I tried to remove that but that didnt do anything either. I only get blanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="39298" data-lia-user-login="AlexisOlson" class="lia-mention lia-mention-user"&gt;AlexisOlson&lt;/a&gt;&amp;nbsp; When I try your&amp;nbsp; measure it gives me values but when I select month beginning like 2020 and month 1, it doesnt show the previous year month value ( it should show month 12 and year 2019) , it just shows blank. I have a filter on the page where I have monthyear when the measure works but as the user wants the date slicer in the format of Jan-2020 , then below measuer wont show me anything although the Jan-2020 is sorted by monthyear. Not sure how to resolve this?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 08:45:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2160382#M49944</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-28T08:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: Getting last month sales without any date table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2160802#M49951</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your feedback.&lt;/P&gt;
&lt;P&gt;I think the reason that my solution gives a result in my model and it does not give any result in your model is because my model and yours are different.&lt;/P&gt;
&lt;P&gt;Without knowing your model, I can only rely on my imagination and I have to create something new.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 12:24:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2160802#M49951</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2021-10-28T12:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: Getting last month sales without any date table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2166326#M50204</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="291628" data-lia-user-login="Jihwan_Kim" class="lia-mention lia-mention-user"&gt;Jihwan_Kim&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just added some dummy data where there is a date slicer int he format of aug 2021 etc and I tried your measures , but it doesnt give me any values? What am I doing wrong?&lt;/P&gt;&lt;P&gt;I just have the file here ;&amp;nbsp;&lt;A href="https://github.com/userdata21/test/blob/main/previous%20month.pbix" target="_blank"&gt;https://github.com/userdata21/test/blob/main/previous%20month.pbix&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Many thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 13:21:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2166326#M50204</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-11-01T13:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Getting last month sales without any date table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2166428#M50210</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your message.&lt;/P&gt;
&lt;P&gt;Please try to fix the measure like below.&lt;/P&gt;
&lt;P&gt;I think RIGHT function and LEFT function are missplaced.&lt;/P&gt;
&lt;P&gt;Mine is starting with month number, but yours is starting with year number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Previous month sales : =&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;EM&gt;VAR yearnumber =&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;INT ( LEFT ( SELECTEDVALUE ( Data[Sort month year] ), 4 ) )&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;VAR monthnumber =&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;INT ( RIGHT ( SELECTEDVALUE ( 'Data'[Sort month year] ), 2 ) )&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;VAR currentyearmonthnumber = yearnumber * 12 + monthnumber&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;RETURN&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;CALCULATE (&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;[Amount Sum],&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;FILTER (&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ALL ( Data ),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;CALCULATE (&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;INT ( LEFT ( SELECTEDVALUE ( Data[Sort month year] ), 4 ) ) * 12&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;+ INT ( RIGHT ( SELECTEDVALUE ( Data[Sort month year] ), 2 ) )&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;) = currentyearmonthnumber - 1&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 14:12:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2166428#M50210</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2021-11-01T14:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: Getting last month sales without any date table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2166514#M50219</link>
      <description>&lt;P&gt;What does your [monthyear] column look like? If it's an integer like 201912, then subtracting 1 from 202001 definitely doesn't give the right result. I'd suggest working with a column that's the last day of the month so you can use &lt;A href="https://dax.guide/eomonth/" target="_blank"&gt;EOMONTH&lt;/A&gt; to shift dates. You might need to create a new calculated column for this but I can't tell you quite how to write one without knowing what [monthyear] looks like.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 14:50:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2166514#M50219</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2021-11-01T14:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: Getting last month sales without any date table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2166537#M50220</link>
      <description>&lt;P&gt;Having looked at your file, here's what I recommend.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Define a new calculated column:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;EoM = EOMONTH ( Data[Date], 0 )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then a measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;PrevMonthSum = 
VAR PrevMonthEnd =
    EOMONTH ( SELECTEDVALUE ( Data[EoM] ), -1 )
RETURN
    CALCULATE ( SUM ( Data[Amount] ), ALLSELECTED ( Data ), Data[EoM] = PrevMonthEnd )&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 01 Nov 2021 14:58:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-last-month-sales-without-any-date-table/m-p/2166537#M50220</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2021-11-01T14:58:59Z</dc:date>
    </item>
  </channel>
</rss>

