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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Getting the average "minutes" in a column


Hey everyone, this is my first time posting in the Power BI community support and I'm just getting started with Power BI.


Can anyone help me solve this problem I have.

I have a column that has the time that a task took to complete in the format HH:MM:SS

so for example one row is this: 86:42:15 
82 Hours, 42 Minutes, 15 Seconds.

 

When I try to get the average for the column it gives me nonsense numbers and it's right I guess cuz it doesn't know what this data is. The format is in text for the moment. Can anyone help with the steps I need to achieve this task?

Thanks in advance

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

Hi @Anonymous ,

 

Check the following formulas.

Column = 
var hours = MID('Table'[Column1],1,2)*60
var minutes = MID('Table'[Column1],4,2)*1
var seconds = MID('Table'[Column1],7,2)/60
var sum_ = hours+minutes+seconds
return
sum_

Column 2 = AVERAGE('Table'[Column])

11.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

3 REPLIES 3
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Check the following formulas.

Column = 
var hours = MID('Table'[Column1],1,2)*60
var minutes = MID('Table'[Column1],4,2)*1
var seconds = MID('Table'[Column1],7,2)/60
var sum_ = hours+minutes+seconds
return
sum_

Column 2 = AVERAGE('Table'[Column])

11.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
mahoneypat
Employee
Employee

Not straight forward, but you can put this formula in a custom column to get the total hours in decimal form that you can use for calculations.

 

= let

hours = Number.FromText(Text.BeforeDelimiter([TimeColumn], ":",0)),
minutes = Number.FromText(Text.BetweenDelimiters([TimeColumn], ":",":")),
seconds = Number.FromText(Text.AfterDelimiter([TimeColumn], ":",1))
in
Duration.TotalHours(#duration(Number.RoundDown(hours/24,0), Number.Mod(hours, 24), minutes, seconds))

 

Regards,

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


AlB
Super User
Super User

Hi @Anonymous 

What data type is the column, text?

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.