<?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: Measure on historical states in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-on-historical-states/m-p/3677173#M142783</link>
    <description>&lt;P&gt;Hi, I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.&lt;/P&gt;
&lt;P&gt;Please check the below picture and the attached pbix file whether it suits your requirement.&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;
&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;LI-CODE lang="markup"&gt;Expected result measure: = 
VAR _currentdate =
    MAX ( 'Calendar'[Date] )
VAR _currentstage =
    VALUES ( Stage[Stage] )
VAR _t =
    SUMMARIZE (
        ALL ( Data ),
        'Calendar'[Date],
        DealID[DealID],
        Stage[Stage],
        Data[Amount]
    )
VAR _lastnonblankdate =
    ADDCOLUMNS (
        _t,
        "@lastnonblankdate",
            MAXX (
                FILTER (
                    _t,
                    DealID[DealID] = EARLIER ( DealID[DealID] )
                        &amp;amp;&amp;amp; 'Calendar'[Date] &amp;lt;= _currentdate
                        &amp;amp;&amp;amp; Data[Amount] &amp;lt;&amp;gt; BLANK ()
                ),
                'Calendar'[Date]
            )
    )
VAR _filter =
    SUMMARIZE ( _lastnonblankdate, DealID[DealID], [@lastnonblankdate] )
RETURN
    SUMX (
        FILTER (
            CALCULATETABLE (
                SUMMARIZE ( Data, 'Calendar'[Date], DealID[DealID], Stage[Stage], Data[Amount] ),
                TREATAS ( _filter, DealID[DealID], 'Calendar'[Date] )
            ),
            Stage[Stage] IN _currentstage
        ),
        Data[Amount]
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 03 Feb 2024 10:42:54 GMT</pubDate>
    <dc:creator>Jihwan_Kim</dc:creator>
    <dc:date>2024-02-03T10:42:54Z</dc:date>
    <item>
      <title>Measure on historical states</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-on-historical-states/m-p/3677030#M142781</link>
      <description>&lt;P&gt;Hi - I have been stuck on this seemingly simple problem for the last couple of days...&lt;BR /&gt;I have a table that stores changes in attributes of objects (Deal ID) that looks like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I have a separate DateDim table and I now need a measure to perform a calculation on the most recent historical state based on a Date slicer.&lt;BR /&gt;So for example on 31/12/2023 Deal ID 25 had an amount 90000 and stage D, and Deal ID 13&amp;nbsp;had an amount 30000 and stage C.&lt;BR /&gt;The measure should then show this result:&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;Many thanks for pointing me in the right direction!&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2024 09:53:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-on-historical-states/m-p/3677030#M142781</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-02-03T09:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: Measure on historical states</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-on-historical-states/m-p/3677173#M142783</link>
      <description>&lt;P&gt;Hi, I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.&lt;/P&gt;
&lt;P&gt;Please check the below picture and the attached pbix file whether it suits your requirement.&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;
&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;LI-CODE lang="markup"&gt;Expected result measure: = 
VAR _currentdate =
    MAX ( 'Calendar'[Date] )
VAR _currentstage =
    VALUES ( Stage[Stage] )
VAR _t =
    SUMMARIZE (
        ALL ( Data ),
        'Calendar'[Date],
        DealID[DealID],
        Stage[Stage],
        Data[Amount]
    )
VAR _lastnonblankdate =
    ADDCOLUMNS (
        _t,
        "@lastnonblankdate",
            MAXX (
                FILTER (
                    _t,
                    DealID[DealID] = EARLIER ( DealID[DealID] )
                        &amp;amp;&amp;amp; 'Calendar'[Date] &amp;lt;= _currentdate
                        &amp;amp;&amp;amp; Data[Amount] &amp;lt;&amp;gt; BLANK ()
                ),
                'Calendar'[Date]
            )
    )
VAR _filter =
    SUMMARIZE ( _lastnonblankdate, DealID[DealID], [@lastnonblankdate] )
RETURN
    SUMX (
        FILTER (
            CALCULATETABLE (
                SUMMARIZE ( Data, 'Calendar'[Date], DealID[DealID], Stage[Stage], Data[Amount] ),
                TREATAS ( _filter, DealID[DealID], 'Calendar'[Date] )
            ),
            Stage[Stage] IN _currentstage
        ),
        Data[Amount]
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2024 10:42:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-on-historical-states/m-p/3677173#M142783</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2024-02-03T10:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Measure on historical states</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-on-historical-states/m-p/3677394#M142788</link>
      <description>&lt;P&gt;This is amazing, it is exactly what I was looking for. I will need to study it for a while, because I don't think I would have ever gotten there by myself. Thank you so much Jihwan_Kim!&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2024 11:40:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-on-historical-states/m-p/3677394#M142788</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-02-03T11:40:53Z</dc:date>
    </item>
  </channel>
</rss>

