Forum Discussion

rains_23's avatar
rains_23
Icon for Helper I rankHelper I
1 year ago

Attendance or count based on 2 fields

Hi,

I have a table, as below and I need to count the employee attendance for the whole month. I want the answer as ABC =3, PQR=4, CDF=3. If I use the count of (Login date) in a matrix it gives correct, but the total does not come as correct. Also I want it based on Division for each month, or week. How do I use this. I used the sumx function, but it is not working. 

 

DivisionEmployee NameLogin DateTimeDay of WeekLocation
1ABC 24/01/2023 00:0050:17.0TuesdayAtrium Door RHS
1ABC 25/01/2023 00:0033:52.0WednesdayAtrium Door RHS
1ABC 31/01/2023 00:0054:14.0TuesdayAtrium Door RHS
1PQR11/01/2023 00:0007:44.0WednesdayAtrium Door RHS
1PQR31/01/2023 00:0025:03.0Tuesday2nd Floor Lift Lobby Door LHS
1PQR11/01/2023 00:0024:06.0WednesdayAtrium Door RHS
2PQR12/01/2023 00:0012:56.0ThursdayAtrium Door RHS
2CDF13/01/2023 00:0012:43.0FridayAtrium Door RHS
2CDF16/01/2023 00:0012:08.0MondayAtrium Door RHS
2CDF17/01/2023 00:0013:19.0TuesdayAtrium Door RHS

9 Replies

  • Hi rains_23 

     

    first add a column to your table as follows:

     

    year_month= format( date , 'YYYYMM')

     

    and then write a measure as follows:

     

    measure employee_count := var tbl = summarize (table , division, employee , year_month ,"cnt", count (employee))

    return

    sumx(tbl , cnt )

     

    If this post helps, then I would appreciate a thumbs up  and mark it as the solution to help the other members find it more quickly.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi rains_23 

     

    When using the count of “Login Date” in the matrix, the total is 10, isn't that what you want? May I ask what you expect the total to be?

    If I use the count of (Login date) in a matrix it gives correct, but the total does not come as correct.

     

    Here is my test result:

    Create new columns with the following DAX:

    MonthYear = FORMAT([Login Date], "YYYY-MM")
    WeekNumber = WEEKNUM([Login Date])

     

     

    Best Regards,
    Jarvis Tang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi rains_23 

       

      There is too little information to see from this screenshot, could you please create a matrix visual showing us the problem you are experiencing using the sample data from the initial post?

      And describe all the relevant fields in the matrix and the measures that might be used.

       

      Best Regards,
      Jarvis Tang
      If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

      • rains_23's avatar
        rains_23
        Icon for Helper I rankHelper I

        Sorry, I was going to post the data I used. All are simple columns. Month is a colum duplicated from Login date. with month format. What it is doing is it is taking the total as 21 in above example, that is number of employees in the month of jan. and not no. of occurence. So If an employee is in month of jan 3 times, it is counting as 1 and not 3