Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be 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

Reply
AnaAlbano
Helper I
Helper I

Employee Status Comparison

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 IDStatusReport_date
61957Active1/1/2023
61957Active2/1/2023
61957Active3/1/2023
61957Active4/1/2023
61957On Leave5/1/2023
1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

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.

vtangjiemsft_0-1698890057017.png

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. 

View solution in original post

5 REPLIES 5
AnaAlbano
Helper I
Helper I

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"))

vtangjiemsft_0-1700036496761.png

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 =

VAR _a=CALCULATE(MAX(Dashboard_HHC[Employee status]),FILTER('Dashboard_HHC',Dashboard_HHC[MyAccess ID]=MAX(Dashboard_HHC[MyAccess ID]) && YEAR(Dashboard_HHC[Report Date_Format])=YEAR(EOMONTH(EARLIER(Dashboard_HHC[Report Date_Format]),-1)) && MONTH(Dashboard_HHC[Report Date_Format])=MONTH(EOMONTH(EARLIER(Dashboard_HHC[Report Date_Format]),-1))))
RETURN IF(ISBLANK(_a),BLANK(),IF(_a=Dashboard_HHC[Employee status],"No change","Change"))
 
Report Date_FormatMyAccess IDEmployee statusFlag Column
1/9/2021xx123On LeaveChange
31/08/2021xx123On LeaveChange
1/8/2021xx123On LeaveChange
31/07/2021xx123On LeaveChange
1/7/2021xx123On LeaveChange
30/06/2021xx123On LeaveChange
1/6/2021xx123On LeaveChange
31/05/2021xx123On LeaveChange
1/5/2021xx123ActiveNo change
30/04/2021xx123ActiveNo change
1/4/2021xx123ActiveNo change
31/03/2021xx123ActiveNo change
1/3/2021xx123ActiveNo change
28/02/2021xx123ActiveNo change
1/2/2021xx123ActiveNo change
31/01/2021xx123ActiveNo change
1/1/2021xx123ActiveNo change
31/12/2020xx123ActiveNo change
1/12/2020xx123ActiveNo change
30/11/2020xx123ActiveNo change
1/11/2020xx123ActiveNo change
31/10/2020xx123ActiveNo change
1/10/2020xx123ActiveNo change
30/09/2020xx123ActiveNo change
1/9/2020xx123ActiveNo change
31/08/2020xx123ActiveNo change
1/8/2020xx123ActiveNo change
31/07/2020xx123ActiveNo change
1/7/2020xx123ActiveNo change
30/06/2020xx123ActiveNo change
1/6/2020xx123ActiveNo change
31/05/2020xx123On LeaveChange
1/5/2020xx123On LeaveChange
30/04/2020xx123On LeaveChange
1/4/2020xx123On LeaveChange
31/03/2020xx123On LeaveChange
1/3/2020xx123On LeaveChange
29/02/2020xx123On LeaveChange
1/2/2020xx123On LeaveChange


Really appreatite your time on it 🙂

Thank you,

Ana 

 

v-tangjie-msft
Community Support
Community Support

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.

vtangjiemsft_0-1698890057017.png

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. 

audreygerred
Super User
Super User

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.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.