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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Idkpowerbi
Helper I
Helper I

Help - Calculating total seconds of a date/time column

q_7_2 (1).PNGq_7.PNG

My input data looks like the right column and power bi recognizes in the following format(text). There are some duration values greater than 24 hours. I am unable to change data type to duration and then to total seconds(throws error). Can someone write a power query code to create a new column which has the total  seconds( for eg., 24*3600+53) when power bi doesn't recognizes that I have more than 24 hours and takes only the remainder hours and minutes. 

3 REPLIES 3
ppm1
Solution Sage
Solution Sage

You can add a custom column with this expression to get total seconds.

 

ppm1_0-1688475432716.png

let 
parsedlist = List.Transform(Text.Split([Duration], ":"), each Number.From(_) )
in 
parsedlist{0}*3600 + parsedlist{1} + parsedlist{2}/100

 

Pat

 

Microsoft Employee

q_7_4.PNG

Actually the problem is that the data is imported from an excel where it uses the format(1/1/1900) to store time more than 24 hours and power query recognizes this as shown above. Can you calculate total seconds from this type. 

That should be easier. Just convert it to a DateTime type first, then convert it to a decimal and, when prompted, choose "Add as a new step". This will give your duration in days, and you can do a multiply transform to convert it to seconds. Or you can leave it as decimal in days, and just multiply to get seconds in your measures.

 

Pat

Microsoft Employee

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors