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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
rains_23
New Member

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 9
rains_23
New Member

The total does not come correct for me ,

 

rains_23_1-1729586885124.png

 

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.

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

 

rains_23_0-1729604891192.png

 

Card details - is employee name

Anonymous
Not applicable

Hi @rains_23 

 

Based on your description, I think you were expecting the totals to be count of Login Date, but the actual result in your matrix looks like count of employee, is that correct? Please correct me if I have misunderstood.


However, I am not able to reproduce the problem using sample data.

vxianjtanmsft_1-1729667338623.png

 

Please check the following first:
1. Check the field settings:
Make sure the Employee, Division and Month fields are not incorrectly set as row labels or key column.

vxianjtanmsft_0-1729667121588.png

2. Data Model Relationships:
Make sure that the Login Date column has the correct relationship to the other tables and that there are no many-to-many relationships.

 

If the problem persists, please create a simple sample Power BI file with sample data to reproduce the problem and share your pbix file here.

 

 

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.

Hi,

Unfortunately I am not able to find the Row Label and Key Column properties in my version. 

 

rains_23_0-1729681646950.png

 

rains_23_1-1729681676346.png

 

 

Anonymous
Not applicable

Hi @rains_23 

 

In the model view, select your table to see the Row lable and Key column.

vxianjtanmsft_0-1729748670109.pngvxianjtanmsft_1-1729748722757.png

As stated in the previous reply, if possible, please create a Power BI file using simple sample data and reproduce the problem, then share that Power BI file here and we'll try to find the cause of the probelm and solve it.

 

 

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

 

vxianjtanmsft_0-1729561083327.pngvxianjtanmsft_1-1729561133219.png

 

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.

Selva-Salimi
Super User
Super User

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.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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