Forum Discussion

AnaAlbano's avatar
AnaAlbano
Helper I
2 years ago
Solved

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
  • Anonymous's avatar
    Anonymous
    2 years ago

    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. 

5 Replies

  • 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.

  • Anonymous's avatar
    Anonymous
    Not applicable

    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 Anonymous! 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? 

    • Anonymous's avatar
      Anonymous
      Not applicable

      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

      • AnaAlbano's avatar
        AnaAlbano
        Helper I

        Thank you Anonymous 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