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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
stubax
Frequent Visitor

Time on Y-Axis

Thought I would show a simple solution for adding time format to Y-Axis of charts as I couldn't find a solution for this - 

starting with a simple dataset below - (time is in time format HH:MM:SS)

 

stubax_5-1685633787612.png

 

Step 1 -

Add a new column turning time into a decimal in hours e.g. 01:30:00 = 1.5 hours 

using formula - 

Decimal Time = Data[Time]*24
stubax_4-1685633728088.png

 

Step 2 -
Add new measure summing this new column
using formula - 
SumofDecimalTime = sum(Data[Decimal Time])
 
Step 3 - 
Add new measure converting SumofDecimalTime measure into time format
using formula - 
HH:MM:SS =
VAR vHoursDecimal = [SumofDecimalTime]
VAR vHours = INT ( vHoursDecimal )
VAR vMinutesDecimal = 60 * ( vHoursDecimal - vHours )
VAR vMinutes = INT ( vMinutesDecimal )
VAR vSeconds = ROUND ( 60 * ( vMinutesDecimal - vMinutes ), 0 )
VAR vHH = IF ( LEN ( vHours ) = 1, "0" & vHours, vHours )
VAR vMM = IF ( LEN ( vMinutes ) = 1, "0" & vMinutes, vMinutes )
VAR vSS = IF ( LEN ( vSeconds ) = 1, "0" & vSeconds, vSeconds )
RETURN
    CONVERT ( vHH & vMM & vSS, INTEGER )
 
Step 4 - change format of new HH:MM:SS measure in the format box to 00:00:00 (have to type this in the box) as in the below - 
stubax_1-1685633122391.png

 

Step 5 - 

Add HH:MM:SS measure into Y-Axis of chart and Date column into X-Axis.

 

Step 6 - 

Change Y-Axis display units to None as in the below - 

stubax_2-1685633485258.png

 The result should be something similar to the below - 

stubax_3-1685633590179.png

Also works with bar charts. Hope this helps anyone struggling with getting time on the Y-Axis.

 

 

 

 

0 REPLIES 0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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