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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Time to integer, and vice versa

Hi all,

 

I have a report where I want a measure that returns the amount of seconds, to be converted to "HH:MM:SS". In the same report for another measure I want a "HH:MM:SS" column to be converted to the ammount of seconds in it as a integer. 

 

Best regards,

L.Meijdam

1 ACCEPTED SOLUTION
DAX0110
Resolver V
Resolver V

Seconds number to Time string:

      =FORMAT( [seconds] / 60 / 60 /24, "hh:nn:ss" )

 

Time string to Seconds number:

      =TIMEVALUE( [time str] ) * 24 * 60 * 60

 

 

View solution in original post

6 REPLIES 6
DAX0110
Resolver V
Resolver V

Seconds number to Time string:

      =FORMAT( [seconds] / 60 / 60 /24, "hh:nn:ss" )

 

Time string to Seconds number:

      =TIMEVALUE( [time str] ) * 24 * 60 * 60

 

 

Anonymous
Not applicable

Hi @DAX0110,

 

The "string to seconds number" is working like expected thankyou very much!

 

The other calculation is giving me a error, although I don't think the formula is incorrect. I want a calculated column that is in "Whole number" format to change the amount of seconds to a time value. But when I use your formula it returns: Cannot convert value '' of type Text to type Date. And I don't really understand why since it is in "Whole number" format.

 

My calculated columnMy calculated column

Best regards,

L.Meijdam

Mmm, that's interesting.  In my test workbook the Power Pivot "seconds" column is "decimal" type with "general" format.

 

If you feed the output column from "string to seconds number" into the "seconds number to string" formula, it should work (I did that to double check my formula).

 

 

Anonymous
Not applicable

Hi @DAX0110,

 

yes I tried that, that is returning the expected outcome. It just does'nt work when I insert my other calculated column.. Anyone have an idea how to fix this ?

 

Best Regards,

L.Meijdam

Anonymous
Not applicable

Hi @Anonymous,

 

I'd like to suggest you take a look at below blog which told about convert duration and time.

Aggregating Duration/Time

 

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Hi,

 

How I fixed it in the end was to SUM my calculated column by creating a measure, and after that using the "Seconds string to time" formula provided by @DAX0110 on that measure.

 

I have read the article @Anonymous linked and I learned some new things for it !

 

Thankyou all 🙂

 

Best regards,

L.Meijdam

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors