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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Converting time value to a decimal number so it could be displayed as a value

Hey everyone,
So initally i had two time values, which was StartTime and EndTime and right now I got the duration between both as one column, but in the duration format. The problem is, I can't figure out how to make it as a decimal or whole number, so I could display it as a sum in histogram. The closest I got to this is take duration as total hours, however, I need precise time to be displayed in the histogram as a value. Any ideas? 

9 REPLIES 9
Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

check out this code

 

let
    StartTime = #time(12,0,0),
    EndTime = #time(16,30,0),
    DurationDigital = Number.From(EndTime-StartTime)*24
in
    DurationDigital

 

Jimmy801_0-1600160060628.png

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Anonymous
Not applicable

It seems like its displaying 4,5, but i would need it to be 4:30(as a decimal number) if that makes sense.
Thanks for your help. 

Anonymous
Not applicable

Hello @Anonymous 

 

4:30 it's text format. Just convert the duration to text. Here the code

let
    StartTime = #time(12,0,0),
    EndTime = #time(16,30,0),
    DurationDigital = Duration.ToText(EndTime-StartTime)
in
    DurationDigital

 

Jimmy801_0-1600165089055.png

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

 

Anonymous
Not applicable

@Jimmy801 

that is basically how I want to do it

Gediminas12_0-1600168980652.png

 

 

Hello @Anonymous 

 

I don't think that you can sum a time-format like "4:30" in Power BI. I don't know how exactly you need to sum and show. But you could make something like this

Jimmy801_0-1600169820660.png

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Anonymous
Not applicable

@Jimmy801  That would be a possible solution how did you do that? can you share your file with me? 

Hello @Anonymous 

 

but I didn't any sum. What i did is to create a column with decimals and a new column1 to format it to "hh:mm".

Jimmy801_0-1600170709870.png

 

in the histrogram I've used Column1 for values and Column for the Axis. I don't know if this could be of any help. But maybe it could be a starting point 🙂

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

 

Anonymous
Not applicable

@Jimmy801 That is what I need, however I can't sum up text value to display it in histogram, any way I could sum up this text format to display it into values? 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors
Top Kudoed Authors