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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Count if DAX Help :)

Hello all,

 

I have two tables, fBrazilBadge (badge swipes for brazil) and fHeadcount (global employee records). fBrazilBadge is linked to a date table. So far I have validated that I am getting the correct counts by date.

 

I am looking to create create a bar chart visual. I need to create a measure(s) that says, if "employee ID equals selected "location ID" count as "1" because I am only looking to calculate the attendance data of people who are pointed to one of the sites in Brazil.

 

e.g. January 7th, I have 10 people badging in. 3 of them have location ID that is not one of the sites in Brazil, the other 7 are. So the 7 people would be counted as having had been on site to their designated work location.

 

Kentucky_0-1668280731866.png

 

1 ACCEPTED SOLUTION
Mikelytics
Resident Rockstar
Resident Rockstar

so I assume that in the headcoun table each employee has only one assgigned location. The measure could look like this

 

Batch-In Count of employees =
SUMX(
   BatchTable,
   CALCULATE(
      IF(SELECTEDVALUE(BatchTable[Location ID] = SELECTEDVALUE(HeadCountTable[Location ID],1,0)
   )
)
   

 

But for my current understanding you would nee to creat the relation via the employee table because you want to check whether the employee batches withint the home location.

 

Best regards

Michael

-----------------------------------------------------

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your thumbs up!

@ me in replies or I'll lose your thread.

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

View solution in original post

3 REPLIES 3
Mikelytics
Resident Rockstar
Resident Rockstar

so I assume that in the headcoun table each employee has only one assgigned location. The measure could look like this

 

Batch-In Count of employees =
SUMX(
   BatchTable,
   CALCULATE(
      IF(SELECTEDVALUE(BatchTable[Location ID] = SELECTEDVALUE(HeadCountTable[Location ID],1,0)
   )
)
   

 

But for my current understanding you would nee to creat the relation via the employee table because you want to check whether the employee batches withint the home location.

 

Best regards

Michael

-----------------------------------------------------

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your thumbs up!

@ me in replies or I'll lose your thread.

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!
Mikelytics
Resident Rockstar
Resident Rockstar

Hi  @Anonymous,

 

First questions which arises for me is: Does the table fHeadcount have an EmployeeID? What is the granularity of this table? Because it seems not right to creat a relation over the location ID.

 

Best regards

Michael

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!
Anonymous
Not applicable

Yes, the  fHeadcount does have employeeID. I did a merge query to do a fuzzy match using name on both fHeadcount and fBrazilBadge to bring EmployeeID to fBrazilBadge as it does not have that data.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.