<?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: Latest status based on date(time) and measurement point in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3270347#M121186</link>
    <description>&lt;P&gt;Thank you so much, this has been working solution!&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jun 2023 11:36:56 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-06-06T11:36:56Z</dc:date>
    <item>
      <title>Latest status based on date(time) and measurement point</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3260987#M120571</link>
      <description>&lt;P&gt;I have a problem which I can't resolve. Case is that we have machines with several measurement points per machine and three different statuses (=warning types). I have COUNTROWS measure for each warning type and those are in table visual where every machine has it's own row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Problem is how can I get latest warning type for each measurement point based on latest measured datetime? It would be easy with just LASTDATE function but when measurement dates differ between measurement point this solution won't work. I need to group measurement point and date or datetime with somehow. I tried just GROUPBY( alarms_table, measurement_point, date ) in CALCULATE function but that won't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is quick sample data that I just made with excel. I highlighted latest measurement date for point P02 which is the problem in this example.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help? Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 05:51:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3260987#M120571</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-05-31T05:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: Latest status based on date(time) and measurement point</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3261090#M120585</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Latest Warning =
MAXX (
    TOPN ( 1, FILTER ( 'Table', 'Table'[Warning Type] &amp;lt;&amp;gt; "Ok" ), 'Table'[DateTime] ),
    'Table'[Warning Type]
)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 31 May 2023 07:05:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3261090#M120585</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-05-31T07:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Latest status based on date(time) and measurement point</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3261229#M120594</link>
      <description>&lt;P&gt;Thank you, I will try that. But I am counting all warning types because there can be several alarms active from several different measurement source system. So basically&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Source1 - P02&lt;/LI&gt;&lt;LI&gt;Source1 - P03&lt;/LI&gt;&lt;LI&gt;Source1 - P04&lt;/LI&gt;&lt;LI&gt;Source2 - P01&lt;/LI&gt;&lt;LI&gt;Source2 - P02&lt;/LI&gt;&lt;LI&gt;Source2 - P03&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I need to count latest warning types from every different source. Here is new picture:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 07:58:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3261229#M120594</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-05-31T07:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: Latest status based on date(time) and measurement point</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3261332#M120603</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;I think I misunderstood the requirement. I believe you want to create three measures (one for each status) to count based on the latest status of each warning type. You can use the following measure structure for "Danger" and "Warning" as well.&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Ok =
SUMX (
    VALUES ( 'Table'[Measurement_Point] ),
    INT (
        NOT ISEMPTY (
            FILTER (
                TOPN ( 1, CALCULATETABLE ( 'Table' ), 'Table'[DateTime] ),
                'Table'[Warning_Type] = "Ok"
            )
        )
    )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 31 May 2023 08:29:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3261332#M120603</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-05-31T08:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: Latest status based on date(time) and measurement point</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3261900#M120675</link>
      <description>&lt;P&gt;Thank you so much, this seems to work perfectly! When I get more data I can validate this better. One thing though. This works in table rows but in totals it won't count all latest warning types from all machines. So basically it need some tweaking when counting totals like this&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Ok =
VAR _latestAlarm =
SUMX (
    VALUES ( 'Table'[Measurement_Point] ),
    INT (
        NOT ISEMPTY (
            FILTER (
                TOPN ( 1, CALCULATETABLE ( 'Table' ), 'Table'[DateTime] ),
                'Table'[Warning_Type] = "Ok"
            )
        )
    )
)

VAR _countTotal =
previous code with some changes

RETURN
IF(
   HASONEVALUE( machine_id ),
   _latestAlarm,
   _countTotal
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 12:50:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3261900#M120675</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-05-31T12:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: Latest status based on date(time) and measurement point</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3261965#M120679</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;Please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Ok =
SUMX (
    SUMMARIZE ( 'Table', 'Table'[Machine_ID], 'Table'[Measurement_Point] ),
    INT (
        NOT ISEMPTY (
            FILTER (
                TOPN ( 1, CALCULATETABLE ( 'Table' ), 'Table'[DateTime] ),
                'Table'[Warning_Type] = "Ok"
            )
        )
    )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 31 May 2023 13:20:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3261965#M120679</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-05-31T13:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: Latest status based on date(time) and measurement point</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3270347#M121186</link>
      <description>&lt;P&gt;Thank you so much, this has been working solution!&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 11:36:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3270347#M121186</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-06-06T11:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: Latest status based on date(time) and measurement point</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3270745#M121218</link>
      <description>&lt;P&gt;Actually I just figured out at there can be ties in DateTime... So there can be "OK" and "Warning" with same timestamp. Is there easy solution to rank those?&amp;nbsp;Luckily I have one other ID column which I can use to break those ties but I don't know how.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit. I think I got it&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":see_no_evil_monkey:"&gt;🙈&lt;/span&gt;. Just added after [DateTime]:&lt;BR /&gt;" , , 'Table'[Alarm_id] " and it seems to give correct results.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 14:40:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Latest-status-based-on-date-time-and-measurement-point/m-p/3270745#M121218</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-06-06T14:40:21Z</dc:date>
    </item>
  </channel>
</rss>

