Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi All
I have this table, which tracks changes to employee status,
and I sorted values of column named [EmployeeID] in ascending order. I am looking for M query that checks if value in column [EmployeeID] is same in next row (meaning that change relates to same employee), then create a column named [EndDate] to show when that [StatusAfter] ended and a column named [CurrentStatus] to show if that status is current.
After this I would merge queries with same table to end up with my desired table, which would be like below;
How can i do that?
Solved! Go to Solution.
Hi,
I have changed 2 dates to try (i don't know if it is true).
refer to fantastic video of Goodly for knowledge
https://www.youtube.com/watch?v=IGF2-qfzDQs
If this post is useful to help you to solve your issue, consider giving the post a thumbs up and accepting it as a solution!
Hi,
I have changed 2 dates to try (i don't know if it is true).
refer to fantastic video of Goodly for knowledge
https://www.youtube.com/watch?v=IGF2-qfzDQs
If this post is useful to help you to solve your issue, consider giving the post a thumbs up and accepting it as a solution!
Hi,
probably you have some problem in your example.
What about ID26 where the current is not the last one?
You can use the following M code to achieve the desired output:
This formula checks if the current [EmployeeID] value is the same as the [EmployeeID] value in the next row. If it is, it subtracts one day from the [EffectiveDate] to get the [EndDate], otherwise it returns null.
This formula checks if the [EndDate] is null, meaning the current row is the latest status for that employee, and returns "Yes" for [CurrentStatus]. Otherwise, it checks if the [EffectiveDate] is equal to the maximum [EffectiveDate] value for that employee, and returns "Yes" for [CurrentStatus] if it is, otherwise it returns "No".
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 10 | |
| 6 | |
| 5 | |
| 4 | |
| 2 |