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
Anonymous
Not applicable

calculate time

Hi all,

 

am using a xls file as a source for a new report and one of the columns is an average of a duration of a visit. The only thing is that it is displayed like this: 9 min 28s and i want to have seconds (568) instead. Any ideas how to solve this.

thnx

M

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

Please try this modified DAX formula to create a calculated column.

Time in seconds =
IF (
    NOT ( ISERROR ( FIND ( "min", Table5[Avg. Visit Duration (in seconds)] ) ) ),
    VALUE ( LEFT ( Table5[Avg. Visit Duration (in seconds)], 2 ) ) * 60
        + VALUE ( LEFT ( RIGHT ( Table5[Avg. Visit Duration (in seconds)], 3 ), 2 ) ),
    VALUE (
        LEFT (
            Table5[Avg. Visit Duration (in seconds)],
            LEN ( Table5[Avg. Visit Duration (in seconds)] ) - 1
        )
    )
)

1.PNG

 

Best regards,
Yuliana Gu

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

View solution in original post

8 REPLIES 8
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Please try below formula. Please notice that in my sample data, there existing space between numeric and text.

Time in seconds =
VALUE ( LEFT ( Table4[Time], 2 ) ) * 60
    + VALUE ( LEFT ( RIGHT ( Table4[Time], 4 ), 2 ) )

1.PNG

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
fhill
Resident Rockstar
Resident Rockstar

Please copy and paste some sample data (or link to a small excel sample) so we can give it a go!  My thoughts are to do a Text Trim of the field Before " min" (convert to number) * 60 + Text Trim After "min " (exclude s).

FOrrest




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




Anonymous
Not applicable

Hi @Anonymous,

 

Can you check if this code(measure) works:

Time = MINUTE(Table[TimeColumn1])*60+SECOND(Table[TimeColumn2])

 

Regards,

L.Meijdam

Anonymous
Not applicable

Hi,

thanks for your reply, tried the formula but Power BI explains that this expression cannot be used/found...

I think it is a format issue of this field as it has numbers and characters in it (9 min 28s).....

Any other ideas?

Anonymous
Not applicable

Hi @Anonymous,

 

Perhaps you could format it to a actual "time" value, or make a new column with actual time data. The problem now is that Power BI sees your values as (probably) text not as a number or time value.

 

Regards,

L.Meijdam

Anonymous
Not applicable

Hi, Hope this will help:

Avg. Visit Duration (in seconds)

2 min 37s

1 min 21s

0s

0s

1 min 14s

5s

45s

9 min 7s

5s

0s

31s

0s

36s

3s

0s

Hi @Anonymous,

 

Please try this modified DAX formula to create a calculated column.

Time in seconds =
IF (
    NOT ( ISERROR ( FIND ( "min", Table5[Avg. Visit Duration (in seconds)] ) ) ),
    VALUE ( LEFT ( Table5[Avg. Visit Duration (in seconds)], 2 ) ) * 60
        + VALUE ( LEFT ( RIGHT ( Table5[Avg. Visit Duration (in seconds)], 3 ), 2 ) ),
    VALUE (
        LEFT (
            Table5[Avg. Visit Duration (in seconds)],
            LEN ( Table5[Avg. Visit Duration (in seconds)] ) - 1
        )
    )
)

1.PNG

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi Yuliana, thanks for your suggestion which works fine!!!

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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