Forum Discussion
Getting an Average Point In Time by Date and Individual
I want two tables, average start time by date, and average start time by employee. The screenshot in my previous post was meant to show the table for average start time by date in which you can see only the min value is being returned, not the average of all start times that occured during that date.
I didn't depict the average start time by employee table but it is doing the same thing.
I have two seperate measures as you described, one for average start time by employee, and one for average start time by date, but both are still just returning the min value.
The measure with the VALUES by date, will certainly work exactly as you described within a table that has 1 column for dates. This is because, row by row, the date column is already doing the same job as VALUES function. Once it gets to the total, thats when you get the correct value.
The measure with the VALUES for employee will work if you have used the correct employee column. If that employee column is from another table compared to your table with badge scans, there will need to be the a 1 to many relationship between those two tables. I'm expecting you either have an employee table where each employee has a badge number, or you have a badge history table which each badge number links back to a single employee. Either way you should be able to create a basic table visual in Power BI where you put the employee as the first column and then their swipe times (with don't summarise) should be able to appear in the 2nd column to show that the modelling works.
- DorienM2 years agoHelper II
Thats it though, this isnt some complex data setup at all. Its all in a single table of badge scan logs.
Table Name: BadgeScans
Badge Number Employee Name Message Location Date/Time Date Only (Added in at transform level) Time Only (Added in at transform level) 01:00023 John Doe Access Granted Main Entry 4/1/2024 9:14:10 AM 4/1/2024 9:14:10 AM 01:00089 Mary Sue Access Granted SE Entrance 4/1/2024 10:03:38 AM 4/1/2024 10:03:38 AM I can't post the whole dataset, but imagine about 10k more rows and John Doe, Mary Sue, and 100 other employees having multiple entries per day.
From this I have two measures written exactly as shown:
Average First Scan by Person = FORMAT(AVERAGEX( VALUES('BadgeScans'[Badge Number]), MIN('BadgeScans'[Time Only]) ),"HH:MM:SS")and
Average First Scan by Day = FORMAT(AVERAGEX( VALUES('BadgeScans'[Date Only], MIN('BadgeScans'[Time Only]) ),"HH:MM:SS")Then add two table visuals to the report. Table 1 has the fields 'Date Only' and 'Average First Scan by Day' on it. Table 2 has the fields 'Badge Number' and 'Average First Scan by Person'. Each row of the table only shows the MIN value by category, not the AVERAGE value by category.
Logically if John Doe came to work every day last week and scanned his badge at 5 doors each day, the would have 25 rows in Badge Scans. I want his average start time though, so I need the average of only 5 of the 25 values in the table, specifically the average of the 5 MIN values by Day.
- Anonymous2 years agoNot applicable
You've got the measures backwards compared to the tables. Table 1 should be the fields 'Date Only' and 'Average First Scan by Person' on it. Table 2 should have the fields 'Badge Number' and 'Average First Scan by Date'
- DorienM2 years agoHelper II
Like this?
Because these are still only the min values. I know this because I am that highlighed badge on the right, I usually arrive around 6:45 AM and am generally the first one in the building that 6:18 is absolutely my earliest.
Most people don't get in until 8 or 9 so I know those are Min values in table 1 as well.