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
patrick_freeman
New Member

Cannot calculate sum of binary Matrix

I am attempting to create a matrix that shows the number of employees clocked in at each point in the day. So far, I have been able to create one that shows who is clocked in at each point based on their clock in and clockout time. However, when attempting to sum the binary values that indicate whether an employee is present or not, I am left with a sum = 1. See attached for the visual and DAX expressions used. 

patrick_freeman_0-1649173472469.pngpatrick_freeman_1-1649173495779.png

 

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @patrick_freeman ,

According to your description, here's my solution.

1.Create a measure, and put the measure in the visual Values.

Column Values = 
VAR StartTime=CALCULATE(MIN('Labor'[Clock In]),ALL('Time'))
VAR EndTime=CALCULATE(MAX('Labor'[Clock Out]),ALL('Time'))
VAR Dur=MIN('Time'[Time])>=StartTime&&MAX('Time'[Time])<=EndTime
VAR _Count=COUNTROWS(FILTER('Labor','Labor'[Clock In]<=MAX('Time'[Time])&&'Labor'[Clock Out]>=MAX('Time'[Time])))
RETURN
IF(Dur,IF(ISINSCOPE(Labor[Name]),1,_Count))

2.Turn on the Column Values backgroud color and font color, both are set to Gradient format.

vkalyjmsft_0-1650354085463.png

vkalyjmsft_1-1650354159456.png

Get the correct result.

vkalyjmsft_2-1650354252922.png

I attach the sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

View solution in original post

5 REPLIES 5
v-yanjiang-msft
Community Support
Community Support

Hi @patrick_freeman ,

According to your description, here's my solution.

1.Create a measure, and put the measure in the visual Values.

Column Values = 
VAR StartTime=CALCULATE(MIN('Labor'[Clock In]),ALL('Time'))
VAR EndTime=CALCULATE(MAX('Labor'[Clock Out]),ALL('Time'))
VAR Dur=MIN('Time'[Time])>=StartTime&&MAX('Time'[Time])<=EndTime
VAR _Count=COUNTROWS(FILTER('Labor','Labor'[Clock In]<=MAX('Time'[Time])&&'Labor'[Clock Out]>=MAX('Time'[Time])))
RETURN
IF(Dur,IF(ISINSCOPE(Labor[Name]),1,_Count))

2.Turn on the Column Values backgroud color and font color, both are set to Gradient format.

vkalyjmsft_0-1650354085463.png

vkalyjmsft_1-1650354159456.png

Get the correct result.

vkalyjmsft_2-1650354252922.png

I attach the sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

tamerj1
Super User
Super User

Hi @patrick_freeman @patrickfreeman 
Would you please share a screenshot of your report?

amitchandak
Super User
Super User

@patrick_freeman , Try a measure like

if(countrows(filter(labor, labor([clock in time]) <= max('Time'[Time]) && labor([clock out time]) >= min('Time'[Time]))) >=1, 1,blank())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Is there a way to make my time column a variable? I am still getting used to DAX and struggling to frame this data in a non-excel way

I appreciate the response. I think I may not have been clear in my first post. Right now, that is the result I'm getting (sum = 1). I am looking to see if I can assign a value to each employee so if I were to take the sum at a certain part of the day the sum = # of employees clocked in (i.e. = 3)

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.

Users online (2,364)