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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
cdizzle22
Frequent Visitor

Formatting Time and Null Time

Hello Community,

 

I am using Power BI to measure the time a ticket was opened using some cold data. The time is built off of when it was put into a resolved state minus when it was opened. The calculation comes back correct but in a decimal format. Does anyone have pointers on how to format this decimal into Days, Hours, Minutes?

 

Also, for tickets that are still open the value in resolved time is null so it returns a gross negative number. Does anyone have pointers on how to treat these null values and possibly replace them with a current date that continuously updates?

 

Thanks!

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @cdizzle22 

 

You can replace null with the current datetime with the following code. Replace "previous step name" with your last step name in Power Query Editor. 

= Table.ReplaceValue(#"previous step name",null,DateTime.LocalNow(),Replacer.ReplaceValue,{"Resolved Time"})

vjingzhang_0-1648091491143.png

 

Then create a custom column with [Resolved Time] - [Open Time] to get the duration. 

vjingzhang_2-1648091861680.png

 

Add another custom column to format the Duration values. The new Duration column will be Text type. 

= Table.AddColumn(#"Added Custom", "Duration new", each Text.From(Duration.Days([Duration])) & "Days," & Text.From(Duration.Hours([Duration])) & "Hours," & Text.From(Duration.Minutes([Duration])) & "Minutes")

vjingzhang_4-1648092251952.png

 

If you want to convert format with DAX method at report side, you can refer to the following blogs:

Converting Decimal Time to Days, Hours, Minutes, Seconds in Power BI • My Online Training Hub

Calculate Duration in Days Hours Minutes and Seconds Dynamically in Power BI using DAX - RADACAD

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @cdizzle22 

 

You can replace null with the current datetime with the following code. Replace "previous step name" with your last step name in Power Query Editor. 

= Table.ReplaceValue(#"previous step name",null,DateTime.LocalNow(),Replacer.ReplaceValue,{"Resolved Time"})

vjingzhang_0-1648091491143.png

 

Then create a custom column with [Resolved Time] - [Open Time] to get the duration. 

vjingzhang_2-1648091861680.png

 

Add another custom column to format the Duration values. The new Duration column will be Text type. 

= Table.AddColumn(#"Added Custom", "Duration new", each Text.From(Duration.Days([Duration])) & "Days," & Text.From(Duration.Hours([Duration])) & "Hours," & Text.From(Duration.Minutes([Duration])) & "Minutes")

vjingzhang_4-1648092251952.png

 

If you want to convert format with DAX method at report side, you can refer to the following blogs:

Converting Decimal Time to Days, Hours, Minutes, Seconds in Power BI • My Online Training Hub

Calculate Duration in Days Hours Minutes and Seconds Dynamically in Power BI using DAX - RADACAD

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

artemus
Microsoft Employee
Microsoft Employee

If you are using the duration data type to do the calculations, you need to add a new column with the value converted to text first. Then once loaded into the model, you need to set the sort column of the text column with the duration to that of the decimal column.

 

If you are only working in decimals in Power Query, you can use a custom column with:

[Ticket_Open_Time] * #duration(1, 0, 0, 0) 

assuming that [Ticket_Open_Time] is the column name that contains the decimal value.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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