<?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: Last sales in Calendar Limiter in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-sales-in-Calendar-Limiter/m-p/3273600#M121409</link>
    <description>&lt;LI-CODE lang="markup"&gt;CALENDAR(curYM-18; curYM-12)&lt;/LI-CODE&gt;
&lt;P&gt;this will not work as each argument of CALENDAR expects a full date, not just a month number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;var currD = min ('Calendar'[Date])
var prevY_YMs = CALENDAR(EDATE(currd,-18),EDATE(currD,-12))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note this will create a series of dates, not months.&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jun 2023 00:12:59 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2023-06-08T00:12:59Z</dc:date>
    <item>
      <title>Last sales in Calendar Limiter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-sales-in-Calendar-Limiter/m-p/3270584#M121202</link>
      <description>&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to make a DAX measure, to find last non empty cell with date limiter. So if there is no sales in current period, the measure should dive into past for 6 month and no longer, and takes the first non blank value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jan 2023 - is a current date&lt;/P&gt;&lt;P&gt;IF Jan 2022 has no sales, it should go to the past between Dec 2021 and Jul 2021.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my code:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=VAR curYM =
    MIN ( 'Calendar'[YM number]) 
VAR prevY_YMs = 
    CALENDAR(curYM-18; curYM-12)
VAR sales = 
    SUMX (
        VALUES ( ACTSALES3[Product] );
        VAR addSales = 
            ADDCOLUMNS (
                prevY_YMs;
                "@sales";
                    VAR ym = [Date]
                    VAR s =
                        CALCULATE (
                            SUM ( ACTSALES3[Sales TRUB] );
                            ALL ( 'Calendar' );
                            'Calendar'[YM number] = DATE(YEAR(ym); MONTH(ym);1)
                        )
                    RETURN
                        s
            )
        VAR filterYMWithSaleRows = 
            FILTER ( addSales; [@sales] &amp;lt;&amp;gt; 0 )
        VAR lastYMWithSaleRows = 
            MAXX ( filterYMWithSaleRows; [Date] )
        VAR filterLMdata = 
            FILTER ( filterYMWithSaleRows; [Date] = lastYMWithSaleRows )
        VAR result = 
            IF ( NOT ISEMPTY ( filterYMWithSaleRows ); SUMX ( filterLMdata; [@sales] ) )
        RETURN
            result
    )
RETURN
    sales&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; If I change&amp;nbsp;VAR prevY_YMs =CALENDAR(curYM-18; curYM-12) to GENERATESERIES it will work perfectly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the question is, to avoid this function. Any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 13:19:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-sales-in-Calendar-Limiter/m-p/3270584#M121202</guid>
      <dc:creator>Aza33ello</dc:creator>
      <dc:date>2023-06-06T13:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: Last sales in Calendar Limiter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-sales-in-Calendar-Limiter/m-p/3273600#M121409</link>
      <description>&lt;LI-CODE lang="markup"&gt;CALENDAR(curYM-18; curYM-12)&lt;/LI-CODE&gt;
&lt;P&gt;this will not work as each argument of CALENDAR expects a full date, not just a month number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;var currD = min ('Calendar'[Date])
var prevY_YMs = CALENDAR(EDATE(currd,-18),EDATE(currD,-12))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note this will create a series of dates, not months.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 00:12:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-sales-in-Calendar-Limiter/m-p/3273600#M121409</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-06-08T00:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Last sales in Calendar Limiter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-sales-in-Calendar-Limiter/m-p/3274197#M121438</link>
      <description>&lt;P&gt;Whoa, it works. Completly forgot about EDATE. Thank you so much, you literally saved my life!!!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 07:57:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-sales-in-Calendar-Limiter/m-p/3274197#M121438</guid>
      <dc:creator>Aza33ello</dc:creator>
      <dc:date>2023-06-08T07:57:18Z</dc:date>
    </item>
  </channel>
</rss>

