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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.