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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Count rows if between a certain time period in PowerQuery

Dear all,

 

For below earlier asked question I've received the following DAX expression, which I'm very grateful for:

 

Your Count = VAR timeFilterStart = 'Datasource'[Timestamp] - TIME(0,0,600)
VAR timeFilterEnd = 'Datasource'[Timestamp]
RETURN
CALCULATE(
    COUNTROWS('Datasource'),
ALL('Datasource'),
    'Datasource'[Timestamp] >= timeFilterStart,
    'Datasource'[Timestamp] <= timeFilterEnd
)
 
I would however like to transfer this DAX to a Powerquery but am struggling to translate it into the right syntax. Is anybody able to help out with this one?
 
Best regards!
 

 

 

Previous post:

 

I have the following issue which I think should be relatively easy to solve, but I have not found a solution yet. Currently I have below table in excel but I would like to get the same result (Column F) in a query in PowerBI.  Basically it comes down to this, Column A is a long list of events happening on the specified date/time. I would like to count how many events happen (F) in a timeframe of 10 minutes (between C and D). Some helper columns are made to come to the result in column F (Column B en E)

 

In Excel the following calculations are applied, but perhaps the calcaluation could be made way easier in PowerBI. Hope somebody could help me out with this one! If more info is needed please let me know.

 

A = raw data

B = VLOOKUP(A2;C$2:E$8527;3)

C = A

D = A + 10 minutes

E = Index column

F= COUNTIF(B:B;E2)

 

Column AColumnBColumnCColumnDColumnEColumnF
TimestampCountTimestartTime + 10 minutesIndexSlice
count
1-09-20 0:00:0411:9:2020 00:00:041:9:2020 00:10:0411
1-09-20 0:02:4821:9:2020 00:02:481:9:2020 00:12:4821
1-09-20 0:14:0731:9:2020 00:14:071:9:2020 00:24:0731
1-09-20 0:24:4941:9:2020 00:24:071:9:2020 00:34:0743
1-09-20 0:27:0441:9:2020 00:34:071:9:2020 00:44:0751
1-09-20 0:31:3741:9:2020 00:44:071:9:2020 00:54:0760
1-09-20 0:35:0451:9:2020 00:54:071:9:2020 01:04:0770
1-09-20 1:15:3591:9:2020 01:04:071:9:2020 01:14:0780
1-09-20 1:19:2391:9:2020 01:14:071:9:2020 01:24:0792
1-09-20 1:24:08101:9:2020 01:24:071:9:2020 01:34:07103
1-09-20 1:25:45101:9:2020 01:34:071:9:2020 01:44:07111
1-09-20 1:33:30101:9:2020 01:44:071:9:2020 01:54:07121
3 REPLIES 3
monica2563
Frequent Visitor

Hello, not sure if this needs to be another wuestion or not, but I pulling data as an admin on datasets. (when and what time they are refreshed). I am trying to count the number of datasets being refreshed every 30 min from 6AM to 10AM daily. I have a column for dataset name, date it was refreshed and start and end time for each one. Again, trying to determin number of items being refreshed. 

 dataset.JPG

mahoneypat
Microsoft Employee
Microsoft Employee

This can be done in query, but these type of calculations are much better done with DAX.  Why do you need this done in the query?  Do you plan to do further data transformations using it?  Please explain what your final goal is and maybe a different approach can be suggested.

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

The reason why I would like to transform it because in DAX I keep getting a calculation error (dataset is over 2MM rows and growing). It was suggested to put the calculation in powerquery to make it easily scalable towards a dataflow (which should be used for large calculations rather than performing them in PowerBI itself). Please let me know your thoughts on this

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors