March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello,
I am trying to get a percentage of how many people came to the office per week and on which floor they were working.
Now my issue is that my only way of tracking that is with the access card database, but people move around all day, so I might get 15 entries per person per day.
I filter each floors on my visual with a dropdown slicer, that's not a problem. My problem is that my distinctcount per day used to randomly pick the row. And my highest percentage was the floor where the cafeteria is, but that's the floor I have the less office. So the percentage doesn't make any sense.
My assumption is that their first entry of the day will be on the floor they'll mostly work on that day.
Access cards | |||||
Name | Floor | Date_Only | Date_Time | DistinctEntryPerDay | |
John Smith | jsmith@contoso.com | 30 | 2024-10-10 | 2024-10-10 8:30 | 2024-10-10 jsmith@contoso.com |
John Smith | jsmith@contoso.com | 34 | 2024-10-10 | 2024-10-10 12:30 | 2024-10-10 jsmith@contoso.com |
John Smith | jsmith@contoso.com | 30 | 2024-10-10 | 2024-10-10 13:30 | 2024-10-10 jsmith@contoso.com |
John Smith | jsmith@contoso.com | 31 | 2024-10-11 | 2024-10-11 9:30 | 2024-10-11 jsmith@contoso.com |
John Smith | jsmith@contoso.com | 34 | 2024-10-11 | 2024-10-11 12:30 | 2024-10-11 jsmith@contoso.com |
John Smith | jsmith@contoso.com | 31 | 2024-10-11 | 2024-10-11 13:30 | 2024-10-11 jsmith@contoso.com |
Bob Loblaw | bloblaw@contoso.com | 32 | 2024-10-10 | 2024-10-10 9:00 | 2024-10-10 bloblaw@contoso.com |
Bob Loblaw | bloblaw@contoso.com | 34 | 2024-10-10 | 2024-10-10 12:00 | 2024-10-10 bloblaw@contoso.com |
Bob Loblaw | bloblaw@contoso.com | 32 | 2024-10-10 | 2024-10-10 15:00 | 2024-10-10 bloblaw@contoso.com |
Solved! Go to Solution.
Hi @Crowdak
To accurately calculate the percentage of employees who came to the office per week and determine on which floor they primarily worked, you can use the first entry of each person per day as their main working floor.
Solution Steps:
Add a calculated column in your 'Access cards' table to identify the floor where each employee made their first entry on each day.
FirstEntryFloor =
VAR FirstTime =
CALCULATE(
MIN('Access cards'[Date_Time]),
FILTER(
'Access cards',
'Access cards'[Email] = EARLIER('Access cards'[Email]) &&
'Access cards'[Date_Only] = EARLIER('Access cards'[Date_Only])
)
)
RETURN
IF(
'Access cards'[Date_Time] = FirstTime,
'Access cards'[Floor],
BLANK()
)
First, ensure you have a Date table linked to your 'Access cards'[Date_Only] column to handle weekly aggregation.
EmployeesPerFloor =
CALCULATE(
DISTINCTCOUNT('Access cards'[Email]),
'Access cards'[FirstEntryFloor] = SELECTEDVALUE('Access cards'[Floor])
)
TotalEmployees = COUNT('Roles Employés RH'[Adresse courriel au bureau])
PercentagePerFloor =
DIVIDE(
[EmployeesPerFloor],
[TotalEmployees],
0
)
Important Notes:
Example Visualization:
By following these steps, you will:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Hi,
First create a calculated column with the followind DAX
FirstEntryFloor =
VAR FirstTime = CALCULATE(
MIN('Access cards'[Date_Time]),
ALLEXCEPT('Access cards', 'Access cards'[Email], 'Access cards'[Date_Only])
)
RETURN
CALCULATE(
MAX('Access cards'[Floor]),
'Access cards'[Date_Time] = FirstTime
)
Now create a measure to calculate the % with the following DAX
Taux de Réservation =
VAR TotalEmployees = CALCULATE(
DISTINCTCOUNT('Access cards'[Email]),
ALL('Access cards')
)
VAR EmployeesPerFloor =
CALCULATE(
DISTINCTCOUNT('Access cards'[Email]),
FILTER(
'Access cards',
'Access cards'[FirstEntryFloor] = SELECTEDVALUE('Access cards'[Floor])
)
)
RETURN
DIVIDE(EmployeesPerFloor, TotalEmployees, 0)
If this answer help you, please give a Kudos and acept as solution.
Regards
Hi @Crowdak
Based on your needs, I have created the following table.
You want to calculate how many people come to the office each week, you first need a column to get the week number corresponding to the date, assuming Monday is the start of the week.
Weeknummber = WEEKNUM('Access cards'[Date_Time],2)
Then you can calculate how many people come to the office each week.
Count per week =
var _selectweek = SELECTEDVALUE('Access cards'[Weeknummber])
RETURN
CALCULATE(DISTINCTCOUNT('Access cards'[Name]),FILTER(ALL('Access cards'),'Access cards'[Weeknummber] = _selectweek))
Percent:
Precent = [Count per week] / COUNT('Roles Employés RH'[Adresse courriel au bureau])
You also want to know which floors they work on. Since the earliest floor employees appear on can change daily, you'll need to use a slicer to pinpoint a specific day within a specific week.
Work floor =
VAR _selectweek = SELECTEDVALUE('Access cards'[Weeknummber])
VAR _selectdate = SELECTEDVALUE('Access cards'[Date_Only])
VAR _selectname = SELECTEDVALUE('Access cards'[Name])
VAR _mintime = MINX(FILTER(ALL('Access cards'),'Access cards'[Weeknummber] = _selectweek && 'Access cards'[Date_Only] = _selectdate && 'Access cards'[Name] = _selectname ),'Access cards'[Date_Time])
VAR _floor = CALCULATE(SELECTEDVALUE('Access cards'[Floor]),FILTER(ALL('Access cards'), 'Access cards'[Weeknummber] = _selectweek && 'Access cards'[Date_Only] = _selectdate && 'Access cards'[Date_Time] = _mintime))
RETURN _floor
Result:
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
First create a calculated column with the followind DAX
FirstEntryFloor =
VAR FirstTime = CALCULATE(
MIN('Access cards'[Date_Time]),
ALLEXCEPT('Access cards', 'Access cards'[Email], 'Access cards'[Date_Only])
)
RETURN
CALCULATE(
MAX('Access cards'[Floor]),
'Access cards'[Date_Time] = FirstTime
)
Now create a measure to calculate the % with the following DAX
Taux de Réservation =
VAR TotalEmployees = CALCULATE(
DISTINCTCOUNT('Access cards'[Email]),
ALL('Access cards')
)
VAR EmployeesPerFloor =
CALCULATE(
DISTINCTCOUNT('Access cards'[Email]),
FILTER(
'Access cards',
'Access cards'[FirstEntryFloor] = SELECTEDVALUE('Access cards'[Floor])
)
)
RETURN
DIVIDE(EmployeesPerFloor, TotalEmployees, 0)
If this answer help you, please give a Kudos and acept as solution.
Regards
Hi,
Based on the data that you have shared, show the expected result.
Hi @Crowdak
To accurately calculate the percentage of employees who came to the office per week and determine on which floor they primarily worked, you can use the first entry of each person per day as their main working floor.
Solution Steps:
Add a calculated column in your 'Access cards' table to identify the floor where each employee made their first entry on each day.
FirstEntryFloor =
VAR FirstTime =
CALCULATE(
MIN('Access cards'[Date_Time]),
FILTER(
'Access cards',
'Access cards'[Email] = EARLIER('Access cards'[Email]) &&
'Access cards'[Date_Only] = EARLIER('Access cards'[Date_Only])
)
)
RETURN
IF(
'Access cards'[Date_Time] = FirstTime,
'Access cards'[Floor],
BLANK()
)
First, ensure you have a Date table linked to your 'Access cards'[Date_Only] column to handle weekly aggregation.
EmployeesPerFloor =
CALCULATE(
DISTINCTCOUNT('Access cards'[Email]),
'Access cards'[FirstEntryFloor] = SELECTEDVALUE('Access cards'[Floor])
)
TotalEmployees = COUNT('Roles Employés RH'[Adresse courriel au bureau])
PercentagePerFloor =
DIVIDE(
[EmployeesPerFloor],
[TotalEmployees],
0
)
Important Notes:
Example Visualization:
By following these steps, you will:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Thanks a lot, it worked 🙂
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
134 | |
91 | |
90 | |
64 | |
58 |
User | Count |
---|---|
201 | |
137 | |
107 | |
72 | |
68 |