Hi
I currently have a table which contains a list of customers with timestamps for when they enter or leave a department. I would like to be able to summarize in some selected period the average and range of the number of people in a department at a certain time. For example, in January the average number of people in department A at 12:00 is 5 and it ranged between 2 and 7 . The way I have achieved this currently is by creating a list of each time period (in this case each hour) using power query and then calculating the number of people in that department at each of these times using a calculated column in power pivot.
The formula I am using for this is:
=Calculate(
DistinctCount([CustomerID]),
Filter(
[Department] = "A" &&
[Time In] <= [Time] &&
[Time Out] > [Time])
)
This produces the correct result, but is really slow to calculate. I am looking for help on whether there is a way to speed up this formula, or whether I am just approaching it wrong in the first place?
I am only using Power Pivot, not power BI, and I have provided a couple of example tables below.
Thanks
I currently have a table which contains a list of customers with timestamps for when they enter or leave a department. I would like to be able to summarize in some selected period the average and range of the number of people in a department at a certain time. For example, in January the average number of people in department A at 12:00 is 5 and it ranged between 2 and 7 . The way I have achieved this currently is by creating a list of each time period (in this case each hour) using power query and then calculating the number of people in that department at each of these times using a calculated column in power pivot.
The formula I am using for this is:
=Calculate(
DistinctCount([CustomerID]),
Filter(
[Department] = "A" &&
[Time In] <= [Time] &&
[Time Out] > [Time])
)
This produces the correct result, but is really slow to calculate. I am looking for help on whether there is a way to speed up this formula, or whether I am just approaching it wrong in the first place?
I am only using Power Pivot, not power BI, and I have provided a couple of example tables below.
Thanks
CustomerID | Department | Time In | Time Out |
---|---|---|---|
1 | A | 1/1/2020 09:50 | 2/1/2020 10:20 |
2 | A | 1/1/2020 11:30 | 1/1/2020 12:05 |
Time | Number of customers in department A (calculated column) |
---|---|
1/1/2020 10:00 | 1 |
1/1/2020 11:00 | 0 |
1/1/2020 12:00 | 1 |