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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
kk_Domme_kk_Aap
Frequent Visitor

Convert negative decimal numbers to time (Long Time)

I'm trying to convert negative decimal numbers to a time displayed as hh:nn:ss (Long Time), however, it's giving me an error:

Screenshot 2022-09-09 152021.png

Instead of converting the "Verschil" column, I also tried to calculate the difference between "Aantal Formated" and "Gepland Formated" but couldn't get far.

6 REPLIES 6
v-yiruan-msft
Community Support
Community Support

Hi  @kk_Domme_kk_Aap ,

Whether your problem has been resolved? If yes, could you please mark the helpful post as Answered? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-yiruan-msft
Community Support
Community Support

Hi @kk_Domme_kk_Aap ,

You can refer the following links to get it:

Converting Decimal Time to Days, Hours, Minutes, Seconds in Power BI

yingyinr_1-1663062551530.png

decimal to duration conversion

NewColumn = 
TRUNC(Table4[Zeit2 - Copy]) & "." &  //Days
FORMAT(TRUNC(Table4[Zeit2 - Copy]*24);"00") & ":" &//Hours  
FORMAT(TRUNC(Table4[Zeit2 - Copy]*24*60);"00") &  ":" & //Minutes
FORMAT(Table4[Zeit2 - Copy]*24*60*60;"00.0000000") //Seconds

Converting “Seconds” to “Duration” in Power BI

 

If the above one can't help you get the desired result, please provide some sample data of the field "Gepland" and "Aantal" (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

Rather than creating a DAX calculated column, consider keeping your column as a decimal, creating your measure and do the formatting at the end (assuming the result is >0, or you will still get an error). Please see this article.

Calculate and Format Durations in DAX – Hoosier BI

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


lbendlin
Super User
Super User

Dates and Times can only ever be positive. What does your column represent?

The "Verschil" column represents the difference in time between "Gepland" and "Aantal"

Then you need to treat it as a duration data type, not a datetime data type. Not sure if negative durations are supported.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.