<?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: Sum of Amount filtered by a recent month in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4075118#M161792</link>
    <description>&lt;P&gt;Thanks for the reply from &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="226664" data-lia-user-login="sjoerdvn" class="lia-mention lia-mention-user"&gt;sjoerdvn&lt;/a&gt;&amp;nbsp;, please allow me to provide another insight:&amp;nbsp;&lt;BR /&gt;Hi&amp;nbsp; Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I created some data:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Here are the steps you can follow：&lt;/P&gt;
&lt;P&gt;1. Create measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Test =
var _select=SELECTCOLUMNS('Open_Items_Table',"Month",[Month])
var _maxmonth=MAXX(ALL('Open_Items_Table'),[Month])
var _table={VALUE(_maxmonth)}
var _column=UNION(_select,_table)
var _count=
CALCULATE(DISTINCTCOUNT('Open_Items_Table'[Month]),ALLSELECTED('Open_Items_Table'))
return
IF(   _count=CALCULATE(DISTINCTCOUNT('Open_Items_Table'[Month]),ALL('Open_Items_Table'))&amp;amp;&amp;amp;HASONEVALUE('Open_Items_Table'[Month])=FALSE(),
    SUMX(
        FILTER(ALL('Open_Items_Table'),
        'Open_Items_Table'[Month] =_maxmonth),[Amount_LC])
    ,
        SUMX(
        FILTER(ALL('Open_Items_Table'),
        'Open_Items_Table'[Month] in _column),[Amount_LC])
)&lt;/LI-CODE&gt;
&lt;P&gt;2. Result:&lt;/P&gt;
&lt;P&gt;No choice:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Select a month:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Select multiple months:&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;Best Regards,&lt;/P&gt;
&lt;P&gt;Liu Yang&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;Accept it as the solution&lt;/EM&gt; to help the other members find it more quickly&lt;/P&gt;</description>
    <pubDate>Fri, 02 Aug 2024 05:46:26 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-08-02T05:46:26Z</dc:date>
    <item>
      <title>Sum of Amount filtered by a recent month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4073693#M161741</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I'm trying to come up with a measure, which will display value in a card visual, showing the sum of Amount_LC for the latest month available in the table, but at the same time I would like it to be compatible with Month slicer (Open_Items_Table[Month]).&lt;BR /&gt;This formula works correctly for summing the values for multiple months selected etc., but it shows the sum of all available months as a default, when no filters are used, but I would like it to display the sum for the recent month only (hence Max month used):&lt;BR /&gt;&lt;BR /&gt;Value of Open Items =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&amp;nbsp;_&lt;SPAN&gt;LatestMonth&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Open_Items_Table&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Open_Items_Table&lt;/SPAN&gt;&lt;SPAN&gt;[Month]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&amp;nbsp;_&lt;SPAN&gt;Amount&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;SUMX&lt;/SPAN&gt;&lt;SPAN&gt;(_&lt;/SPAN&gt;&lt;SPAN&gt;LatestMonth&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Open_Items_Table&lt;/SPAN&gt;&lt;SPAN&gt;[Amount_LC]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&amp;nbsp;_&lt;SPAN&gt;Amount&lt;BR /&gt;&lt;BR /&gt;Hope somebody could help, thanks.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 01 Aug 2024 13:37:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4073693#M161741</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-01T13:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of Amount filtered by a recent month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4073887#M161746</link>
      <description>&lt;LI-CODE lang="markup"&gt;Value of Open Items =
VAR _LatestMonth = MAX(Open_Items_Table[Month])
RETURN CACULATE(SUM(Open_Items_Table[Amount_LC]),Open_Items_Table[Month]=_LatestMonth)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 01 Aug 2024 14:55:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4073887#M161746</guid>
      <dc:creator>sjoerdvn</dc:creator>
      <dc:date>2024-08-01T14:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of Amount filtered by a recent month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4073961#M161749</link>
      <description>&lt;P&gt;Hi, thanks for replying. That measure shows Max Month as a default, but when filtered by multiple months, it doesn't summarize for these months, is it possible to modify to show cumulative values?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 15:35:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4073961#M161749</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-01T15:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of Amount filtered by a recent month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4073973#M161751</link>
      <description>&lt;P&gt;Well, this is all that I can guess with the information you provided. I would need more information to see what's going on and what you are trying to achieve.&lt;BR /&gt;I hope you used the code as a measure and not as a computed column.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 15:42:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4073973#M161751</guid>
      <dc:creator>sjoerdvn</dc:creator>
      <dc:date>2024-08-01T15:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of Amount filtered by a recent month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4073982#M161753</link>
      <description>&lt;P&gt;Yes, I used that as a measure and I achieved the same result as you previously, by using this dax:&lt;/P&gt;&lt;P&gt;Value of Open Items =&lt;/P&gt;&lt;P&gt;VAR &lt;SPAN&gt;_LatestMonth = &lt;SPAN&gt;MAX(Open_Items_Table[Month])&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;VAR &lt;SPAN&gt;_Filter = &lt;SPAN&gt;FILTER(Open_Items_Table, Open_Items_Table[Month] = &lt;SPAN&gt;_LatestMonth)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;VAR &lt;SPAN&gt;_Amount = &lt;SPAN&gt;SUMX(&lt;SPAN&gt;_Filter, Open_Items_Table[Amount_LC])&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;RETURN &lt;SPAN&gt;_Amount&lt;BR /&gt;When unfiltered, it retrieves value for the recent month (6 in this case), when filtered by month 5, it will show total for May, but I would also want it to show values for both, when filtered by 5 &amp;amp; 6 at the same time, hope that makes it more clear?&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 15:46:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4073982#M161753</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-01T15:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of Amount filtered by a recent month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4073999#M161755</link>
      <description>&lt;P&gt;ok, try this&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Value of Open Items =
VAR _LatestMonth = MAX(Open_Items_Table[Month])
RETURN IF(ISFILTERED(Open_Items_Table[Month])
	,SUM(Open_Items_Table[Amount_LC])
	,CALCULATE(SUM(Open_Items_Table[Amount_LC]),Open_Items_Table[Month]=_LatestMonth)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 01 Aug 2024 15:59:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4073999#M161755</guid>
      <dc:creator>sjoerdvn</dc:creator>
      <dc:date>2024-08-01T15:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of Amount filtered by a recent month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4075118#M161792</link>
      <description>&lt;P&gt;Thanks for the reply from &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="226664" data-lia-user-login="sjoerdvn" class="lia-mention lia-mention-user"&gt;sjoerdvn&lt;/a&gt;&amp;nbsp;, please allow me to provide another insight:&amp;nbsp;&lt;BR /&gt;Hi&amp;nbsp; Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I created some data:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Here are the steps you can follow：&lt;/P&gt;
&lt;P&gt;1. Create measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Test =
var _select=SELECTCOLUMNS('Open_Items_Table',"Month",[Month])
var _maxmonth=MAXX(ALL('Open_Items_Table'),[Month])
var _table={VALUE(_maxmonth)}
var _column=UNION(_select,_table)
var _count=
CALCULATE(DISTINCTCOUNT('Open_Items_Table'[Month]),ALLSELECTED('Open_Items_Table'))
return
IF(   _count=CALCULATE(DISTINCTCOUNT('Open_Items_Table'[Month]),ALL('Open_Items_Table'))&amp;amp;&amp;amp;HASONEVALUE('Open_Items_Table'[Month])=FALSE(),
    SUMX(
        FILTER(ALL('Open_Items_Table'),
        'Open_Items_Table'[Month] =_maxmonth),[Amount_LC])
    ,
        SUMX(
        FILTER(ALL('Open_Items_Table'),
        'Open_Items_Table'[Month] in _column),[Amount_LC])
)&lt;/LI-CODE&gt;
&lt;P&gt;2. Result:&lt;/P&gt;
&lt;P&gt;No choice:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Select a month:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Select multiple months:&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;Best Regards,&lt;/P&gt;
&lt;P&gt;Liu Yang&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;Accept it as the solution&lt;/EM&gt; to help the other members find it more quickly&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2024 05:46:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4075118#M161792</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-02T05:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of Amount filtered by a recent month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4075569#M161822</link>
      <description>&lt;P&gt;Exactly what I needed, simple and brilliant! Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2024 08:55:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4075569#M161822</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-02T08:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of Amount filtered by a recent month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4076343#M161860</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;As a best practice, try to avoid SUMX or any "X" function if not really needed. If it cannot be avoided try not to iterate over entire tables, but restrict to single columns or aggregations.&amp;nbsp;&lt;BR /&gt;SUMX over a million rows fact table will have a lousy performance. &lt;BR /&gt;As always with DAX, there are multiple ways of solving the issue above, but using SUMX here is just not a good idea.&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2024 15:36:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-Amount-filtered-by-a-recent-month/m-p/4076343#M161860</guid>
      <dc:creator>sjoerdvn</dc:creator>
      <dc:date>2024-08-02T15:36:23Z</dc:date>
    </item>
  </channel>
</rss>

