<?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: calculating sum for max date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculating-sum-for-max-date/m-p/1086469#M15539</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="195903" data-lia-user-login="czaldumbide" class="lia-mention lia-mention-user"&gt;czaldumbide&lt;/a&gt; , try like&lt;/P&gt;
&lt;P&gt;measure =&lt;BR /&gt;var _max = MAXX('Sales','Sales'[Date] )&lt;BR /&gt;return &lt;BR /&gt;CALCULATE(SUM('Sales'[Amount]), FILTER ('Sales', 'Sales'[Date] =_max ))&lt;/P&gt;</description>
    <pubDate>Tue, 12 May 2020 17:11:32 GMT</pubDate>
    <dc:creator>amitchandak</dc:creator>
    <dc:date>2020-05-12T17:11:32Z</dc:date>
    <item>
      <title>calculating sum for max date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculating-sum-for-max-date/m-p/1086348#M15528</link>
      <description>&lt;P&gt;I created a matrix with the product name as rows, and the sum of amount for the latest purchase date as the value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the following measure for my value:&amp;nbsp;&lt;/P&gt;&lt;P&gt;CALCULATE(SUM('Sales'[Amount]), FILTER ('Sales', 'Sales'[Date] = MAX('Sales'[Date] )))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even though the matrix displays the correct grand total in the table, I still get product names that do not have a record for the latest date of my table, and instead of showing a BLANK value they display the SUM('Sales'[Amount]) that belongs to the latest date that product appeared in the table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lets say my latest date of the table is 11/05/2020. Let me modify my measure to be the following:&lt;/P&gt;&lt;P&gt;CALCULATE(SUM('Transactions'[Amount]), FILTER ('Transactions', 'Transactions'[Date] = DATE(2020,05,11))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This measure does give me the right matrix, but I want my&amp;nbsp; latest date to be automated. Can anyone help me understand why is this happening and what I can do to fix it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 16:04:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculating-sum-for-max-date/m-p/1086348#M15528</guid>
      <dc:creator>czaldumbide</dc:creator>
      <dc:date>2020-05-12T16:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: calculating sum for max date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculating-sum-for-max-date/m-p/1086375#M15530</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="195903" data-lia-user-login="czaldumbide" class="lia-mention lia-mention-user"&gt;czaldumbide&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The MAX() in your measure will give you the latest date for the product in that row, since products is part of the filter context. Try this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure =
VAR latestdate_ =
    MAX ( ALL ( 'Sales'[Date] ) )
RETURN
    CALCULATE (
        SUM ( 'Sales'[Amount] ),
        FILTER ( 'Sales', 'Sales'[Date] = latestdate_ )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;STRONG&gt;Please mark the question solved when done and consider &lt;FONT color="#FF9900"&gt;giving kudos if posts are helpful.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Contact me privately for support with any larger-scale BI needs&lt;/P&gt;
&lt;P&gt;Cheers&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 16:26:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculating-sum-for-max-date/m-p/1086375#M15530</guid>
      <dc:creator>AlB</dc:creator>
      <dc:date>2020-05-12T16:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: calculating sum for max date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculating-sum-for-max-date/m-p/1086469#M15539</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="195903" data-lia-user-login="czaldumbide" class="lia-mention lia-mention-user"&gt;czaldumbide&lt;/a&gt; , try like&lt;/P&gt;
&lt;P&gt;measure =&lt;BR /&gt;var _max = MAXX('Sales','Sales'[Date] )&lt;BR /&gt;return &lt;BR /&gt;CALCULATE(SUM('Sales'[Amount]), FILTER ('Sales', 'Sales'[Date] =_max ))&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 17:11:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculating-sum-for-max-date/m-p/1086469#M15539</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-05-12T17:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: calculating sum for max date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculating-sum-for-max-date/m-p/1087125#M15564</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="195903" data-lia-user-login="czaldumbide" class="lia-mention lia-mention-user"&gt;czaldumbide&lt;/a&gt;&amp;nbsp;，&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure =
VAR latestdate_ =
    CALCULATE (
        MAX ( 'Sales'[Date] ),
        ALLSELECTED ( 'Sales' ),
        VALUES ( 'Sales'[product] )
    )
RETURN
    CALCULATE (
        SUM ( 'Sales'[Amount] ),
        FILTER ( 'Sales', 'Sales'[Date] = latestdate_ )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 05:40:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculating-sum-for-max-date/m-p/1087125#M15564</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-13T05:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: calculating sum for max date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculating-sum-for-max-date/m-p/1087668#M15582</link>
      <description>&lt;P&gt;There are several things wrong with your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, you are creating a filter out of the whole expanded fact table. THIS IS VERY, VERY BAD and slows down calculations tremendously. If you start doing such calculations on big fact tables, you'll feel the heat instantly. One of the golden rules of DAX programming says: &lt;STRONG&gt;Never filter a table if you can filter a column&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Secondly, you should have a Calendar dimension in your model.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do have a proper Calendar, then you can write:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[Latest Sales Amount] =
var __latestSalesDate =
	CALCULATE(
		// This is the very latest
		// day with any sales in it
		// with no regard to any
		// selections in any slicers.
		MAX( Sales[Date] ),
		ALL( Sales )
	)
var __result = 
	CALCULATE(
		SUM( Sales[Amount] ),
		// This only works correctly
		// if Calendar is THE date table
		// in the model.
		Calendar[Date] = __latestSalesDate
	)
return
	__result&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;Best&lt;BR /&gt;D&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 10:24:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculating-sum-for-max-date/m-p/1087668#M15582</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-13T10:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: calculating sum for max date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculating-sum-for-max-date/m-p/2049070#M46052</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="92178" data-lia-user-login="AlB" class="lia-mention lia-mention-user"&gt;AlB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a similar situation for aggregated column. How to create it? Please help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Measure =&lt;BR /&gt;VAR latestdate_ =&lt;BR /&gt;MAX ( ALL ( 'Sales'[Date] ) )&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUM ( 'Sales'[Amount] ),&lt;BR /&gt;FILTER ( 'Sales', 'Sales'[Date] = latestdate_ )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 13:55:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculating-sum-for-max-date/m-p/2049070#M46052</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-31T13:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: calculating sum for max date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculating-sum-for-max-date/m-p/3028573#M103385</link>
      <description>&lt;P&gt;hi,&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;CALCULATE(SUM('Sales'[Amount]), FILTER ('Sales', 'Sales'[Date] = MAX('Sales'[Date] )))&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;the same metric, wen i pulled in , it is blank and it needs always date column to b pulled in along wit it , to get the data. Is there a way to populate the amount for max date without pulling the datekey in the report rows?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2023 12:24:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/calculating-sum-for-max-date/m-p/3028573#M103385</guid>
      <dc:creator>SPriya19</dc:creator>
      <dc:date>2023-01-18T12:24:54Z</dc:date>
    </item>
  </channel>
</rss>

