<?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 Max Less than 1 in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Max-Less-than-1/m-p/4135935#M164286</link>
    <description>&lt;P&gt;I want to show sales based on the most recent month minus one. The below dax shows the sales for max month (June). But I am looking to build another measure that Sums May. (Max-1) I cant use the actual month number or month name becuase I want the formula to be dynamic for when I load additional months (August, September, etc)&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Sales]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;[Month Number]&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;[Month Number]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&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;</description>
    <pubDate>Thu, 05 Sep 2024 16:50:59 GMT</pubDate>
    <dc:creator>keckraguilar</dc:creator>
    <dc:date>2024-09-05T16:50:59Z</dc:date>
    <item>
      <title>Max Less than 1</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Max-Less-than-1/m-p/4135935#M164286</link>
      <description>&lt;P&gt;I want to show sales based on the most recent month minus one. The below dax shows the sales for max month (June). But I am looking to build another measure that Sums May. (Max-1) I cant use the actual month number or month name becuase I want the formula to be dynamic for when I load additional months (August, September, etc)&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Sales]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;[Month Number]&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;[Month Number]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&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;</description>
      <pubDate>Thu, 05 Sep 2024 16:50:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Max-Less-than-1/m-p/4135935#M164286</guid>
      <dc:creator>keckraguilar</dc:creator>
      <dc:date>2024-09-05T16:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Max Less than 1</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Max-Less-than-1/m-p/4135947#M164287</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="736208" data-lia-user-login="keckraguilar" class="lia-mention lia-mention-user"&gt;keckraguilar&lt;/a&gt;&amp;nbsp;Try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
  VAR __MaxMonth = MAXX( ALL( 'Table' ), 'Table'[Month Number] )
  VAR __Result = SUMX( FILTER( ALL( 'Table' ), [Month Number] = __MaxMonth - 1 ), [Sales] )
RETURN
  __Result&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2024 16:56:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Max-Less-than-1/m-p/4135947#M164287</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2024-09-05T16:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: Max Less than 1</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Max-Less-than-1/m-p/4136059#M164297</link>
      <description>&lt;P&gt;This Works! I forgot that the table actually has multiple years. (see table below) Is it possible to add a dynamic filter for max year as well? Basically I would only want May from year 2021 and not 2020.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;</description>
      <pubDate>Thu, 05 Sep 2024 18:41:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Max-Less-than-1/m-p/4136059#M164297</guid>
      <dc:creator>keckraguilar</dc:creator>
      <dc:date>2024-09-05T18:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: Max Less than 1</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Max-Less-than-1/m-p/4139997#M164503</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="736208" data-lia-user-login="keckraguilar" class="lia-mention lia-mention-user"&gt;keckraguilar&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a measure with the following DAX:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;PreviousMonthSales = 
VAR CurrentM = MAX('DataTable'[Month Number])
VAR CurrentY = MAX('DataTable'[Year])
VAR PreviousM = IF(CurrentM = 1, 12, CurrentM - 1)
VAR PreviousY = IF(CurrentM = 1, CurrentY - 1, CurrentY)
RETURN
CALCULATE(
    SUM('DataTable'[Sales]),
    FILTER(
        'DataTable',
        'DataTable'[Month Number] = PreviousM &amp;amp;&amp;amp;
        'DataTable'[Year] = PreviousY
    )
)&lt;/LI-CODE&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;Best Regards,&lt;BR /&gt;Jarvis Tang&lt;BR /&gt;If this post &lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2024 06:46:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Max-Less-than-1/m-p/4139997#M164503</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-09T06:46:42Z</dc:date>
    </item>
  </channel>
</rss>

