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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
labuser1235
Helper IV
Helper IV

Count of Time in a column

HI All,

 

I have a table where time is calculated where it is more than 24 hours, so I convert that in number first and then multiply with 24 in the calculated column. I would like to find the count of those columns which are in between 0-24hrs, 24-48hrs and more than 48hours. Any help on this situation. I believe dax should be done on number*24 column because time above 24hours cannot be brought in a perfect way in Power BI.

 

NameTimeTime to NumberNumber*24
Name115:15:000.6415.25
Name235:35:001.4835.58
Name3495:30:0020.65495.5

 

Thanks in advance.

1 ACCEPTED SOLUTION
v-gizhi-msft
Community Support
Community Support

Hi,

 

According to your description, i create a table to test:

62.PNG

Then split [time] column into hour, minute and second:

61.PNG

Please try this calculated column:

Column = SWITCH(true,'Table'[Time.1]<=24&&'Table'[Time.1]>=0,"0-24",'Table'[Time.1]>24&&'Table'[Time.1]<=48,"24-48",'Table'[Time.1]>48,"48+")

Then create a measure to count them:

Measure = COUNTROWS('Table')

The result shows:

63.PNG

Hope this helps.

 

Best Regards,

Giotto Zhi

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@labuser1235 , Did the last solution work out for you?

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

Yes @amitchandak it worked out for me. 

v-gizhi-msft
Community Support
Community Support

Hi,

 

According to your description, i create a table to test:

62.PNG

Then split [time] column into hour, minute and second:

61.PNG

Please try this calculated column:

Column = SWITCH(true,'Table'[Time.1]<=24&&'Table'[Time.1]>=0,"0-24",'Table'[Time.1]>24&&'Table'[Time.1]<=48,"24-48",'Table'[Time.1]>48,"48+")

Then create a measure to count them:

Measure = COUNTROWS('Table')

The result shows:

63.PNG

Hope this helps.

 

Best Regards,

Giotto Zhi

@v-gizhi-msft How did you bring time which is more than 24 hours into Power BI. When I try to bring hours >24 from excel to Power BI it just shows in number format. 

What format should we have in excel so that we can get it more than 24 hours to Power BI any suggestions on that.

Hi,

 

Please make this time column to text format in excel.

 

Best Regards,

Giotto Zhi

@v-gizhi-msft Sure, I shall try that and get back to you on this.

vivran22
Community Champion
Community Champion

Hello @labuser1235 

 

It is not clear whether you want an additional column or not for the category. In case you want an additional column, you can do this using Power Query > Add Column > Conditional Column:

 

Capture1.PNG

 

In case you do not need an additional column, but a measure to calculate it:

 

0-24 Hours =
COUNTAX ( 'Table', IF ( 'Table'[Number*24] < 24, 'Table'[Number*24] ) )


24-48 Hours = 
COUNTAX (
    'Table',
    IF ( 'Table'[Number*24] >= 24 && 'Table'[Number*24] <= 48, 'Table'[Number*24] )
)

More than 48 = 
COUNTAX (
    'Table',
    IF ( 'Table'[Number*24] > 48, 'Table'[Number*24] )
)

 

This is the output you can get:

 

Capture3.PNG

 

Regards,
Vivek

If it helps, please mark it as a solution

Kudos would be a cherry on the top 🙂

https://www.vivran.in/

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors