March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi Commnity,
I have a dataset which contains a row for each employee each month and the status of the employee can change. How could I compare if the status has changed from the current month versus the previous one?
Thank you so much!
Employee ID | Status | Report_date |
61957 | Active | 1/1/2023 |
61957 | Active | 2/1/2023 |
61957 | Active | 3/1/2023 |
61957 | Active | 4/1/2023 |
61957 | On Leave | 5/1/2023 |
Solved! Go to Solution.
Hi @AnaAlbano ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) We can create a measure.
Measure =
var _a=CALCULATE(MAX('Table'[Status]),FILTER(ALLSELECTED('Table'),'Table'[Employee ID]=MAX('Table'[Employee ID]) && YEAR(MAX('Table'[Report_date]))=YEAR(EOMONTH('Table'[Report_date],1)) && MONTH(MAX('Table'[Report_date]))=MONTH(EOMONTH('Table'[Report_date],1))))
return IF(ISBLANK(_a),BLANK(),IF(_a=MAX('Table'[Status]),"No change","Change"))
(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you @v-tangjie-msft! I tried that and it partially worked, my problem is to aggregate to show by BU, for exemple. Do you think it could be possible to have as a flag column in the table instead of a measure?
Hi @AnaAlbano ,
You can create a flag column.
Flag Column =
var _a=CALCULATE(MAX('Table'[Status]),FILTER('Table','Table'[Employee ID]=MAX('Table'[Employee ID]) && YEAR('Table'[Report_date])=YEAR(EOMONTH(EARLIER('Table'[Report_date]),-1)) && MONTH('Table'[Report_date])=MONTH(EOMONTH(EARLIER('Table'[Report_date]),-1))))
return IF(ISBLANK(_a),BLANK(),IF(_a='Table'[Status],"No change","Change"))
Best Regards,
Neeko Tang
Thank you @v-tangjie-msft for your hard working to help me! It did work as a column. However, the issue is that the objective is to represent the change from a month to another and in this formula, when the status changes, the flag keeps informing "change". For instance, in June/21, we want to show all status changes from May/21 and not carry the changes that happened in other months.
I tried to upload pbix, but it I cannot see this option. This is my real tabel with fake MyAccess ID:
Formula:
Flag Column =
Report Date_Format | MyAccess ID | Employee status | Flag Column |
1/9/2021 | xx123 | On Leave | Change |
31/08/2021 | xx123 | On Leave | Change |
1/8/2021 | xx123 | On Leave | Change |
31/07/2021 | xx123 | On Leave | Change |
1/7/2021 | xx123 | On Leave | Change |
30/06/2021 | xx123 | On Leave | Change |
1/6/2021 | xx123 | On Leave | Change |
31/05/2021 | xx123 | On Leave | Change |
1/5/2021 | xx123 | Active | No change |
30/04/2021 | xx123 | Active | No change |
1/4/2021 | xx123 | Active | No change |
31/03/2021 | xx123 | Active | No change |
1/3/2021 | xx123 | Active | No change |
28/02/2021 | xx123 | Active | No change |
1/2/2021 | xx123 | Active | No change |
31/01/2021 | xx123 | Active | No change |
1/1/2021 | xx123 | Active | No change |
31/12/2020 | xx123 | Active | No change |
1/12/2020 | xx123 | Active | No change |
30/11/2020 | xx123 | Active | No change |
1/11/2020 | xx123 | Active | No change |
31/10/2020 | xx123 | Active | No change |
1/10/2020 | xx123 | Active | No change |
30/09/2020 | xx123 | Active | No change |
1/9/2020 | xx123 | Active | No change |
31/08/2020 | xx123 | Active | No change |
1/8/2020 | xx123 | Active | No change |
31/07/2020 | xx123 | Active | No change |
1/7/2020 | xx123 | Active | No change |
30/06/2020 | xx123 | Active | No change |
1/6/2020 | xx123 | Active | No change |
31/05/2020 | xx123 | On Leave | Change |
1/5/2020 | xx123 | On Leave | Change |
30/04/2020 | xx123 | On Leave | Change |
1/4/2020 | xx123 | On Leave | Change |
31/03/2020 | xx123 | On Leave | Change |
1/3/2020 | xx123 | On Leave | Change |
29/02/2020 | xx123 | On Leave | Change |
1/2/2020 | xx123 | On Leave | Change |
Really appreatite your time on it 🙂
Thank you,
Ana
Hi @AnaAlbano ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) We can create a measure.
Measure =
var _a=CALCULATE(MAX('Table'[Status]),FILTER(ALLSELECTED('Table'),'Table'[Employee ID]=MAX('Table'[Employee ID]) && YEAR(MAX('Table'[Report_date]))=YEAR(EOMONTH('Table'[Report_date],1)) && MONTH(MAX('Table'[Report_date]))=MONTH(EOMONTH('Table'[Report_date],1))))
return IF(ISBLANK(_a),BLANK(),IF(_a=MAX('Table'[Status]),"No change","Change"))
(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You could assign a numerical value to each status then compare the numerical values month to month.
For example, if you do Active as 0 and On Leave as 1, then when you do a MoM if the status is the same the difference will be 0 which will indicate no change. If the difference is > or < 0 it would indicate a change.
Proud to be a Super User! | |
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
129 | |
90 | |
75 | |
58 | |
53 |
User | Count |
---|---|
200 | |
104 | |
101 | |
67 | |
55 |