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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
pgiorgi1
Frequent Visitor

Count rows filtered by duration

it seems straightforward but I am at a loss.

 

I have a data set that that i have been able to create a column for duration in hours minutes and seconds  12:12:12

 

now I need to count the rows of  how many events by 

 

0 - 30 second

31 - 59 seconds

1 - 5 minutes

5- 10 minutes

and 10 minutes +

 

I tried this 

30 seconds to 1 minute =
  CALCULATE(
    DISTINCTCOUNT('NOTES (2)'[Duration])
    ,FILTER('NOTES (2)'
      ,[Duration] >= 0
      && 'NOTES (2)'[Duration] <=1
    )
  )

 but it does not capture the time in fillter properly, 

 

any suggestions on how I filter this into these categories?

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@pgiorgi1 , Create a new column like

 

Bucket =

var _sec = hours([Time])*3600 +Minute([Time])*60 + Second([Time])

return

Switch(True(),

_sec <30 , "  0- 30 Sec",

_sec <60 , " 30- 59 Sec",

_sec<300, "<5 Mins" ,

_sec<600, "<10 Mins" ,

"More than 10 Mins"

)

 

Switch-Case statement of #PowerBI: https://www.youtube.com/watch?v=gelJWktlR80&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=56

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
v-jialluo-msft
Community Support
Community Support

Hi pgiorgi1,

 

According to your description, your question is that you need to count according to the time of each row.

This question is not complicated, but requires you to provide sample files, or illustrate how the time is calculated.

You can try:

30 seconds to 1 minute =
  CALCULATE(
    COUNTROWS('NOTES (2)')
    ,FILTER(ALL('NOTES (2)')
      ,[Duration] >= 0
      && 'NOTES (2)'[Duration] <=1
    )
  )

Best Regards,

Gallen Luo

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@pgiorgi1 , Create a new column like

 

Bucket =

var _sec = hours([Time])*3600 +Minute([Time])*60 + Second([Time])

return

Switch(True(),

_sec <30 , "  0- 30 Sec",

_sec <60 , " 30- 59 Sec",

_sec<300, "<5 Mins" ,

_sec<600, "<10 Mins" ,

"More than 10 Mins"

)

 

Switch-Case statement of #PowerBI: https://www.youtube.com/watch?v=gelJWktlR80&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=56

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
FreemanZ
Super User
Super User

what does 0 or 1 mean for Duration?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.