<?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: Return last Value by Date and grouped by ID in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Return-last-Value-by-Date-and-grouped-by-ID/m-p/3940147#M153195</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It could be that your analysis need only one set of data: &amp;lt;YourTableName&amp;gt;[changedTo] column value is "Active"?&lt;/P&gt;
&lt;P&gt;If yes then one of possible option is to use Power Query step to filter only that column and this status.&lt;/P&gt;</description>
    <pubDate>Wed, 22 May 2024 14:55:48 GMT</pubDate>
    <dc:creator>some_bih</dc:creator>
    <dc:date>2024-05-22T14:55:48Z</dc:date>
    <item>
      <title>Return last Value by Date and grouped by ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Return-last-Value-by-Date-and-grouped-by-ID/m-p/3939640#M153173</link>
      <description>&lt;P&gt;Hello folks,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have a problem that has been bothering me for a few days now. I have a log table that shows the state change of a position (ID).&lt;BR /&gt;I would now like to use the log to determine which positions were set to "Active" in each fiscal week.&lt;BR /&gt;The "result" tables needs the explicit IDs for further calculations, but for now I want to calculate the number of positions per fiscal week.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Example Log:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My first theory thought was to filter the log by fiscal week and then summarize it by position_id and get the Latest "changedTo" for each position_id. Then i would filter the summarized table and volià ... All active positions.&lt;/P&gt;&lt;P&gt;But annoyingly, the technical DAX implementation is lacking on my part.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;As far as i understand, it is not possible to reference a column of a "variable table". So something like this would not work .. (hardcored _curKW for testing)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;VAR _curKW = 202421
VAR _filteredStateChange =
CALCULATETABLE(
'EmploymentPosition StateChange',
'EmploymentPosition StateChange'[ISO YearFW] &amp;lt; _curKW
)
VAR _lastPosState_inKW =
SUMMARIZE(
_filteredStateChange,
'EmploymentPosition StateChange'[employmentPosition_id],
"LastChange",
MAX(_filteredStateChange[changedTo])
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Unfortunately, I can't think of any other way - would anyone here have any ideas to steer me in the right direction?&lt;/P&gt;&lt;P&gt;I would be grateful for any help!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards!&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 11:50:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Return-last-Value-by-Date-and-grouped-by-ID/m-p/3939640#M153173</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-05-22T11:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: Return last Value by Date and grouped by ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Return-last-Value-by-Date-and-grouped-by-ID/m-p/3940147#M153195</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It could be that your analysis need only one set of data: &amp;lt;YourTableName&amp;gt;[changedTo] column value is "Active"?&lt;/P&gt;
&lt;P&gt;If yes then one of possible option is to use Power Query step to filter only that column and this status.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 14:55:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Return-last-Value-by-Date-and-grouped-by-ID/m-p/3940147#M153195</guid>
      <dc:creator>some_bih</dc:creator>
      <dc:date>2024-05-22T14:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: Return last Value by Date and grouped by ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Return-last-Value-by-Date-and-grouped-by-ID/m-p/3940220#M153199</link>
      <description>&lt;P&gt;Hey! Thanks for your reply.&lt;BR /&gt;Unfortunately, that wouldn't work. For the final visualisation, the values should be displayed depending on the calendar week.&lt;BR /&gt;For example, if position 1234 is set to active in calendar week 1, inactive in calendar week 3 and active again in calendar week 4 and position 9876 is set so active in week 2 and inactive in week 4 then the calculated table (simplified) should look like this (The variable _curKW would normally be SELECTEDVALUE(Calendar[YearFiscalWeek] )&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For YearFiscalWeek = 202402&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;employmentPosition_id&lt;/TD&gt;&lt;TD&gt;LastChange&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1234&lt;/TD&gt;&lt;TD&gt;Active&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;9876&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;Active&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;So there are two active positions in Week 02&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For YearFiscalWeek = 202403&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;employmentPosition_id&lt;/TD&gt;&lt;TD&gt;LastChange&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1234&lt;/TD&gt;&lt;TD&gt;Inactive&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;9876&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;Active&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Active Positions in Week 03 = 1&lt;BR /&gt;&lt;BR /&gt;I hope my explanations are reasonably understandable. &lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;//Edit: Found an example in the logfile!&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I filter the log to active only, both employmentPositions would be counted both in FiscalWeek 19 (Pink - which would be correct) and in FiscalWeek 20 (yellow), which would be wrong, as they have been set to inactive.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 15:31:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Return-last-Value-by-Date-and-grouped-by-ID/m-p/3940220#M153199</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-05-22T15:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Return last Value by Date and grouped by ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Return-last-Value-by-Date-and-grouped-by-ID/m-p/3940836#M153221</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;so basically, your expected results should be which employee was active during each fiscal weeks?&lt;/P&gt;
&lt;P&gt;If yes, one approach is to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ADDCOLUMNS (&lt;BR /&gt;SUMMARIZE (YourCentralTableName, FiscalweekID, EmployeeID), "Number of distinct stautus", CALCULATE (DISTINCTCOUNT(YourTableName), column changed to="Active"))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After that filter this table using variable to status Active or what is your definition for Active, as you have blank in column changed to.&lt;/P&gt;
&lt;P&gt;The best would be to share file and provide expected examples.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 21:36:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Return-last-Value-by-Date-and-grouped-by-ID/m-p/3940836#M153221</guid>
      <dc:creator>some_bih</dc:creator>
      <dc:date>2024-05-22T21:36:03Z</dc:date>
    </item>
  </channel>
</rss>

