Running count by hour of the day

Waimea

Active Member
Joined
Jun 30, 2018
Messages
465
Office Version
  1. 365
Platform
  1. Windows
Hi, I have crossposted a similar thread at Re: "Running Count by Hour of the Day" thread and no solution has been found.

I am looking at #15 from the original thread, which can be found Running Count by Hour of the Day [SOLVED].

I am trying to understand exactly what this DAX formula does.

VBA Code:
Active Customers:=CALCULATE (
        COUNTROWS ( Customers ),
        FILTER (
            Customers,
            Customers[Exit Time] >= MIN( Times[Time] ) &&
            Customers[Arrival Time] <= MAX ( Times[End Time] )
        )
    )

I would be glad if someone can help me to understand this DAX formula bit for bit?

Se #15 in original thread for Times[Time] table.
.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
What is it you do not understand? Basically it filters a table called "Customers" where the time is between an interval, comparing Exit/Arrival time to a Time table in which I suspect Time - End Time is an hourly interval. With this filter applied on the Customer Table the number of records/rows are counted. Calculate is required to have the filter applied on the measure "countrows" and it will overwrite the "normal" filter context of your PowerPivot.
 
Upvote 0
Hi GraH,

thank you very much for your reply.

Does it show me how many customers where in my store in a particular hourly interval?

Say a customer enters my store at 10:15 and leaves 11:10.

What does this DAX formula tell me about that visit?
 
Upvote 0
Looking at the formula I'd say this visit in counted at the interval "11-12". Since Exit time is greater the 11 and Arrival time is smaller then 12. Now the thread says running count... But I'm not sure about that as I'm very rusty when it comes down to DAX as I hardly/never need it at work. And you need to keep the practise to see through the formulas so to speak: it's a mental thing, right. Let's wait on others to enlighten you.
PS: I don't have access to the files on that forum, otherwise we could simply look "under the hood".
 
Upvote 0
Hi GraH,

thank you for your reply. I don't think that I can attach files on this forum and I don't have any good means to share a file.

I want to count the number of customers that enters my store for a given time span, per 15 minute periods would be kick-***!

All help is very much appreciated!
 
Upvote 0
Questions:
Do you really have a lot of data?
How well do you understand the concepts of DAX and PowerPivot?

Alternative might be simpler, using a flooring/ceiling formula and a standard pivot.

Book1
DEFGHIJKL
3TimeCount15Min RoundUp15Min RoundDownHours15Min RoundUp15Min RoundDownSum of Count
412/04/2020 11:30112/04/2020 11:4512/04/2020 11:300:00:451
512/04/2020 1:07112/04/2020 1:1512/04/2020 1:00:15:002
612/04/2020 22:33112/04/2020 22:4512/04/2020 22:300 Total3
712/04/2020 11:21112/04/2020 11:3012/04/2020 11:151:15:002
812/04/2020 14:26112/04/2020 14:3012/04/2020 14:15:45:302
912/04/2020 23:14112/04/2020 23:1512/04/2020 23:001 Total4
1012/04/2020 9:54112/04/2020 10:0012/04/2020 9:452:00:451
1112/04/2020 7:27112/04/2020 7:3012/04/2020 7:15:15:003
1212/04/2020 21:28112/04/2020 21:3012/04/2020 21:15:30:151
1312/04/2020 13:46112/04/2020 14:0012/04/2020 13:45:45:301
1412/04/2020 0:12112/04/2020 0:1512/04/2020 0:002 Total6
1512/04/2020 8:43112/04/2020 8:4512/04/2020 8:303:00:451
1612/04/2020 10:29112/04/2020 10:3012/04/2020 10:15:45:301
1712/04/2020 6:25112/04/2020 6:3012/04/2020 6:153 Total2
1812/04/2020 21:54112/04/2020 22:0012/04/2020 21:454:00:451
1912/04/2020 4:41112/04/2020 4:4512/04/2020 4:30:45:301
2012/04/2020 23:45113/04/2020 0:0012/04/2020 23:454 Total2
2112/04/2020 2:09112/04/2020 2:1512/04/2020 2:005:45:301
2212/04/2020 2:08112/04/2020 2:1512/04/2020 2:005 Total1
2312/04/2020 21:13112/04/2020 21:1512/04/2020 21:006:00:451
2412/04/2020 21:36112/04/2020 21:4512/04/2020 21:30:30:153
2512/04/2020 22:40112/04/2020 22:4512/04/2020 22:306 Total4
2612/04/2020 12:24112/04/2020 12:3012/04/2020 12:157:00:451
2712/04/2020 15:03112/04/2020 15:1512/04/2020 15:00:30:151
2812/04/2020 2:45112/04/2020 3:0012/04/2020 2:45:45:302
2912/04/2020 2:42112/04/2020 2:4512/04/2020 2:307 Total4
3012/04/2020 9:27112/04/2020 9:3012/04/2020 9:158:15:001
3112/04/2020 0:07112/04/2020 0:1512/04/2020 0:00:45:301
3212/04/2020 13:29112/04/2020 13:3012/04/2020 13:158 Total2
3312/04/2020 6:25112/04/2020 6:3012/04/2020 6:159:00:451
3412/04/2020 21:03112/04/2020 21:1512/04/2020 21:00:30:151
3512/04/2020 18:52112/04/2020 19:0012/04/2020 18:45:45:301
3612/04/2020 15:09112/04/2020 15:1512/04/2020 15:009 Total3
3712/04/2020 18:33112/04/2020 18:4512/04/2020 18:3010:00:454
3812/04/2020 11:08112/04/2020 11:1512/04/2020 11:00:15:002
3912/04/2020 12:51112/04/2020 13:0012/04/2020 12:45:30:151
4012/04/2020 21:58112/04/2020 22:0012/04/2020 21:45:45:302
4112/04/2020 23:14112/04/2020 23:1512/04/2020 23:0010 Total9
4212/04/2020 19:27112/04/2020 19:3012/04/2020 19:1511:00:452
4312/04/2020 11:35112/04/2020 11:4512/04/2020 11:30:15:001
4412/04/2020 19:20112/04/2020 19:3012/04/2020 19:15:30:152
4512/04/2020 19:10112/04/2020 19:1512/04/2020 19:00:45:304
4612/04/2020 10:51112/04/2020 11:0012/04/2020 10:4511 Total9
4712/04/2020 10:04112/04/2020 10:1512/04/2020 10:0012:00:451
4812/04/2020 7:33112/04/2020 7:4512/04/2020 7:30:30:152
4912/04/2020 11:25112/04/2020 11:3012/04/2020 11:15:45:301
5012/04/2020 10:56112/04/2020 11:0012/04/2020 10:4512 Total4
5112/04/2020 4:46112/04/2020 5:0012/04/2020 4:4513:00:451
5212/04/2020 21:39112/04/2020 21:4512/04/2020 21:30:15:001
5312/04/2020 11:49112/04/2020 12:0012/04/2020 11:45:30:151
5412/04/2020 16:25112/04/2020 16:3012/04/2020 16:1513 Total3
5512/04/2020 3:39112/04/2020 3:4512/04/2020 3:3014:00:451
5612/04/2020 1:31112/04/2020 1:4512/04/2020 1:30:30:151
5712/04/2020 6:26112/04/2020 6:3012/04/2020 6:1514 Total2
5812/04/2020 19:43112/04/2020 19:4512/04/2020 19:3015:00:451
5912/04/2020 11:47112/04/2020 12:0012/04/2020 11:45:15:002
6012/04/2020 21:34112/04/2020 21:4512/04/2020 21:3015 Total3
6112/04/2020 18:20112/04/2020 18:3012/04/2020 18:1516:15:001
6212/04/2020 11:43112/04/2020 11:4512/04/2020 11:30:30:153
6312/04/2020 14:55112/04/2020 15:0012/04/2020 14:45:45:301
6412/04/2020 19:35112/04/2020 19:4512/04/2020 19:3016 Total5
6512/04/2020 6:49112/04/2020 7:0012/04/2020 6:4517:00:451
6612/04/2020 10:47112/04/2020 11:0012/04/2020 10:4517 Total1
6712/04/2020 16:27112/04/2020 16:3012/04/2020 16:1518:00:451
6812/04/2020 2:08112/04/2020 2:1512/04/2020 2:00:30:151
6912/04/2020 1:42112/04/2020 1:4512/04/2020 1:30:45:301
7012/04/2020 12:28112/04/2020 12:3012/04/2020 12:1518 Total3
7112/04/2020 2:24112/04/2020 2:3012/04/2020 2:1519:15:002
7212/04/2020 0:48112/04/2020 1:0012/04/2020 0:45:30:152
7312/04/2020 1:06112/04/2020 1:1512/04/2020 1:00:45:302
7412/04/2020 10:39112/04/2020 10:4512/04/2020 10:3019 Total6
7512/04/2020 19:00112/04/2020 19:1512/04/2020 19:0020:00:451
7612/04/2020 10:39112/04/2020 10:4512/04/2020 10:3020 Total1
7712/04/2020 7:57112/04/2020 8:0012/04/2020 7:4521:00:452
7812/04/2020 9:44112/04/2020 9:4512/04/2020 9:30:15:002
7912/04/2020 13:00112/04/2020 13:1512/04/2020 13:00:30:152
8012/04/2020 8:01112/04/2020 8:1512/04/2020 8:00:45:303
8112/04/2020 23:12112/04/2020 23:1512/04/2020 23:0021 Total9
8212/04/2020 5:41112/04/2020 5:4512/04/2020 5:3022:45:303
8312/04/2020 7:34112/04/2020 7:4512/04/2020 7:3022 Total3
8412/04/2020 17:52112/04/2020 18:0012/04/2020 17:4523:00:451
8512/04/2020 21:15112/04/2020 21:3012/04/2020 21:15:15:003
8612/04/2020 15:53112/04/2020 16:0012/04/2020 15:4523 Total4
8712/04/2020 10:55112/04/2020 11:0012/04/2020 10:45Grand Total93
8812/04/2020 11:38112/04/2020 11:4512/04/2020 11:30
8912/04/2020 16:10112/04/2020 16:1512/04/2020 16:00
9012/04/2020 3:54112/04/2020 4:0012/04/2020 3:45
9112/04/2020 22:35112/04/2020 22:4512/04/2020 22:30
9212/04/2020 10:09112/04/2020 10:1512/04/2020 10:00
9312/04/2020 20:52112/04/2020 21:0012/04/2020 20:45
9412/04/2020 16:15112/04/2020 16:3012/04/2020 16:15
9512/04/2020 12:35112/04/2020 12:4512/04/2020 12:30
9612/04/2020 16:31112/04/2020 16:4512/04/2020 16:30
Sheet1
Cell Formulas
RangeFormula
F4:F96F4=CEILING.MATH(D4,TIME(0,15,0))
G4:G96G4=FLOOR.MATH(D4,TIME(0,15,0))
 
Upvote 0
Hi GraH,

thank you for your time and your reply!

I have lots of data and that's why I turned towards PowerPivot and DAX, I have +1 million rows.

I am currently reading DAX Formulas for PowerPivot 2nd Edition and I have a data model and I am using the DAX formula in the top of the thread.

However, I don't understand completely what the DAX formula does and that makes me weary and that is why I started this thread!
 
Upvote 0
It is a good book. If I recall correctly, Rob talks about the greatest formula in the world in one of the chapters, and that's a nested calculate/filter combo ;).
To test the measure, you can make a pivot with all dimensions required (customer, day, enter and exit times) and filter the pivot (tabular form) as you think the measure works. Then count the records and so if that adds up to the same total with the measure.
 
Upvote 0

Forum statistics

Threads
1,223,794
Messages
6,174,643
Members
452,575
Latest member
Fstick546

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top