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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nizukan
Regular Visitor

DAX - Find sum of users clocked in without clocking out

I am Trying to calculate how many people are currently in a building. When someone enters they will clock in and clock out on exit. 
I am searching for a Dax formula to find the count of all people who have clocked in the past 12 hours and did not clock out yet.

I tried doing this by finding each users last clock in w/o clocking out and is less than 12 hours. Howeve I can't seem to get a sum of the measure.dax clocked in.PNG

 

1 ACCEPTED SOLUTION

I think you would need to summarize your table before being able to count the rows you're looking for. For a table like this:

 

snagit1.jpg

 

you could get a count of people who've clocked in but have not clocked out by using something like this as a measure:

 

HEADCOUNT = SUMX(
SUMMARIZECOLUMNS(Table1[Person],
"STILLINBUILDING",IF(CALCULATE(MAX(Table1[Time]),Table1[Type]="In")-CALCULATE(MAX(Table1[Time]),Table1[Type]="Out") > 0, 1, 0)),
[STILLINBUILDING]
)

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

 

Try this

 

=IF(HASONEVALUE('Syslog SystemEvents[Name]),[your measure],SUMX(SUMMARIZE(VALUES('Syslog SystemEvents[Name]),[Name],"ABCD",[your measure]),[ABCD]))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Super User
Super User

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks I understand know why  that the total is being evalutated just for that total row.

 

I am still trying to figure out how to write a measure to gives me the users currently clocked in but not clocked out yet.

I am trying to count the rows of users who have whos latest recent  entry is greater than their exit.

Any help is appreciated.

I think you would need to summarize your table before being able to count the rows you're looking for. For a table like this:

 

snagit1.jpg

 

you could get a count of people who've clocked in but have not clocked out by using something like this as a measure:

 

HEADCOUNT = SUMX(
SUMMARIZECOLUMNS(Table1[Person],
"STILLINBUILDING",IF(CALCULATE(MAX(Table1[Time]),Table1[Type]="In")-CALCULATE(MAX(Table1[Time]),Table1[Type]="Out") > 0, 1, 0)),
[STILLINBUILDING]
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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