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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
aishak12
Helper IV
Helper IV

Distinct count and find average

All,

 

I have two tables. I would like to create a visual that counts the total number of employees who came in on each specific day. 


For example this is my dataset. Now I want to plot a chart that shows the weekdays (MON-SUN) and on my thursday bar it should show total count of 3. 

(August 17th, 2023) - Thursday - Employee ID: 1027

(August 24th, 2023) - Thursday - Employee ID:1027

(August 31st, 2023) - Thursday - Employee ID: 1028



 

Table A)

- List of employees who came into office 

aishak12_0-1691332984207.png

 

 

Table B)

- Max Capacity of seats in office 

aishak12_1-1691333023372.png

 

 

Also I would like to divide the total numbers of employees attending (the 3 in my example) by the "HEADCOUNT". So am I able to divide these even though they are different tables? 

2 REPLIES 2
BA_Pete
Super User
Super User

Hi @aishak12 ,

 

I'm assuming that TableB only ever has one row per office i.e. it's a dimension table.

If so, then the following should work for you:

 

Create a proper calendar table and add a [DayOfWeek] column to it - there's plenty of guides online how to do this so I won't go into detail here.

 

Relate your calendar table to TableA on: Calendar[Date] ONE = MANY TableA[ex_date].

Relate TA and TB on: TableB[Office] ONE = MANY TableA[Office].

 

Create 2 measures:

 

_noofInWork = DISTINCTCOUNT(TableA[EmployeeID])
_noofInWork_%ofHeadcount = DIVIDE(MAX(TableB[HEADCOUNT]), [_noofInWork], 0)

 

 

In your visual, place Calendar[DayOfWeek], TableB[Office], [_noofInWork] and/or [_noofInWork_%ofHeadcount].

 

If your TableA contains more than seven days' worth of data, you may also need to add a [Week] column into your Calendar table so you can distinguish between different Mondays, Tuesdays etc.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




foodd
Super User
Super User

Please provide your work-in-progress Power BI Desktop file (with sensitive information removed) that covers your issue or question completely in a usable format (not as a screenshot).

https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

This allows members of the Forum to assess the state of the model, report layer, relationships, and any DAX applied.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.