<?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: Using last date in Date Slicer Range to obtain value in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-last-date-in-Date-Slicer-Range-to-obtain-value/m-p/1074070#M15032</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="227763" data-lia-user-login="jwkuyper" class="lia-mention lia-mention-user"&gt;jwkuyper&lt;/a&gt;&amp;nbsp;&amp;nbsp;A couple of things you can play with.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try using LASTDATE instead of MAX.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Careful with your DAX context. You may need to look at using EARLIER or Variables to hard code that Max Quarter Value into the calculation, otherwise it is free to change with the context of the FILTER function it is nested within.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a good intro to variables to help you out:&amp;nbsp;&lt;A href="https://www.sqlbi.com/articles/variables-in-dax/" target="_blank"&gt;https://www.sqlbi.com/articles/variables-in-dax/&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 05 May 2020 22:52:34 GMT</pubDate>
    <dc:creator>AllisonKennedy</dc:creator>
    <dc:date>2020-05-05T22:52:34Z</dc:date>
    <item>
      <title>Using last date in Date Slicer Range to obtain value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-last-date-in-Date-Slicer-Range-to-obtain-value/m-p/1073485#M15015</link>
      <description>&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;I have this slicer, which is based off of a date hierarchy.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I have this table.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;As you can see I also have the following measure that is calculating the last date in the above slicer's selected range. Also to prove that my measure is correct, I have included the column 'Latest Month End Date' to show that my measure and the last date in the slicer are matching.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Max_Quarter_Value = 
MAXX(
    KEEPFILTERS(VALUEs('AUM Source'[Month End Date])),
    CALCULATE(MAX('AUM Source'[Month End Date]))
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;My issue is -- I want to show 'End AUM Test' as the ending AUM for that last period in the selected range, '09/30/2020' in this case. Right now 'End AUM test' is summing all quarters from the above selecected range. As you can see from the below card:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;EM&gt;this summed will equal $621B matching table above&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;My current code for 'End AUM Test' is below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;End AUM Test = 
    CALCULATE(
        SUM('AUM Source'[Value]),
        Filter(
            'AUM Source',
        and(
            'AUM Source'[ShortAcctName]="End AUM", 
            'AUM Source'[Month End Date].[Date]=[Max_Quarter_Value]
        )))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 16:47:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-last-date-in-Date-Slicer-Range-to-obtain-value/m-p/1073485#M15015</guid>
      <dc:creator>jwkuyper</dc:creator>
      <dc:date>2020-05-05T16:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using last date in Date Slicer Range to obtain value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-last-date-in-Date-Slicer-Range-to-obtain-value/m-p/1074070#M15032</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="227763" data-lia-user-login="jwkuyper" class="lia-mention lia-mention-user"&gt;jwkuyper&lt;/a&gt;&amp;nbsp;&amp;nbsp;A couple of things you can play with.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try using LASTDATE instead of MAX.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Careful with your DAX context. You may need to look at using EARLIER or Variables to hard code that Max Quarter Value into the calculation, otherwise it is free to change with the context of the FILTER function it is nested within.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a good intro to variables to help you out:&amp;nbsp;&lt;A href="https://www.sqlbi.com/articles/variables-in-dax/" target="_blank"&gt;https://www.sqlbi.com/articles/variables-in-dax/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 22:52:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-last-date-in-Date-Slicer-Range-to-obtain-value/m-p/1074070#M15032</guid>
      <dc:creator>AllisonKennedy</dc:creator>
      <dc:date>2020-05-05T22:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using last date in Date Slicer Range to obtain value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-last-date-in-Date-Slicer-Range-to-obtain-value/m-p/1074203#M15046</link>
      <description>&lt;LI-CODE lang="markup"&gt;// If you create a correct model, then your calculation will be
// also correct. For a correct model you need:
// 1. An Account dimension.
// 2. A proper Calendar dimension.
// 3. A fact table (AUM Source) that joins to them.
// All columns in a fact table must always be hidden and
// slicing must take place via dimensions only.
// Then your measure is this:

End AUM = 
    CALCULATE(
        SUM( 'AUM Source'[Value] ),
        KEEPFILTERS( Account[Short Acct Name] = "End AUM" ),
        LASTDATE( 'Calendar'[Date] )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;D&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 00:56:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-last-date-in-Date-Slicer-Range-to-obtain-value/m-p/1074203#M15046</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-06T00:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Using last date in Date Slicer Range to obtain value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-last-date-in-Date-Slicer-Range-to-obtain-value/m-p/1074226#M15048</link>
      <description>By the way, your measure above is wrong for many reasons (in fact, too many to talk about here) but the main is that you don't seem to understand what "context transition" is and when it happens. You are getting a sum for the whole period selected because measures, when calculated by iterators, perform context transition. As a result, [Max_Quarter_Value] on each row of 'AUM Source' has exactly the same value as [Month End Date].[Date].&lt;BR /&gt;&lt;BR /&gt;My advice to you is this. Please learn about DAX and stick to the proper dimensional modelling principles. You'll save yourself countless hours of grief and frustration. Here's something to get you started on your way to understanding DAX and data modelling:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://www.youtube.com/watch?v=_quTwyvDfG0" target="_blank"&gt;https://www.youtube.com/watch?v=_quTwyvDfG0&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.youtube.com/watch?v=78d6mwR8GtA" target="_blank"&gt;https://www.youtube.com/watch?v=78d6mwR8GtA&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;And here's something about proper time-intel:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://www.sqlbi.com/tv/time-intelligence-in-microsoft-power-bi/" target="_blank"&gt;https://www.sqlbi.com/tv/time-intelligence-in-microsoft-power-bi/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Hope it'll help you.&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
      <pubDate>Wed, 06 May 2020 01:06:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-last-date-in-Date-Slicer-Range-to-obtain-value/m-p/1074226#M15048</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-06T01:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: Using last date in Date Slicer Range to obtain value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-last-date-in-Date-Slicer-Range-to-obtain-value/m-p/1076604#M15111</link>
      <description>&lt;P&gt;This was very good advice. I used LASTDATE instead of MAX and also created a variable within my measure as you recommended. This works, thank you.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;End AUM Based on Last Date in Slicer = 
   
VAR
    EndDate = LASTDATE('AUM Source'[Month End Date])
Return

CALCULATE(
    sum('AUM Source'[End AUM]),
            'AUM Source'[Month End Date] = EndDate) &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 16:11:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-last-date-in-Date-Slicer-Range-to-obtain-value/m-p/1076604#M15111</guid>
      <dc:creator>jwkuyper</dc:creator>
      <dc:date>2020-05-06T16:11:27Z</dc:date>
    </item>
  </channel>
</rss>

