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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Mgrstrg
New Member

How to convert Time column to seconds

Hello,

I'm new to power bi and I have a column that already has time as hh:mm:ss but I need to get the average and everytime I try it only gives me the option of earliest or latest. I've tried a measure =average('table[column]) but it doesn't work.

 

Mgrstrg_0-1625026267133.png

 

2 REPLIES 2
Anonymous
Not applicable

You can very easily do it:

[Measure] =
CONVERT(
    AVERAGEX(
        'Table',
        1 * 'Table'[Column]
    ),
    datetime
)
Anonymous
Not applicable

hi @Mgrstrg 

 

Usually Time Value cannot be Averaged out since it is not a mathematical expression. Though there is an alternate way to find the mid value of different Time. 

1. Convert Time into Integer. It can be done using

TimeInInt = HOUR(Table1[Time])*3600+MINUTE(Table1[Time]*60)+SECOND(Table1[Time])

2. Take Average of this number. It can be done using

TimeAvg =  CALCULATE(Average(TimeInInt))

3. Convert this Integer back to Time. Please refer below Article for exact calculation

 

Solved: Convert An Int Field to Time Format - Microsoft Power BI Community

 

Please let me know if this works!

 

Thanks!!!

 

Kindly accept the solution if you agree 🙂 and would love to have Kudos if you like!!!

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors