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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

DAX code

Hey guys, 
I'll try to describe my issue as detailed as possible. So in my report i am aggregating time using Chelsie Eiden's Duration model, where it lets me have whole number in time format and that way use it in the values field in the histogram. This part works great, however there is a metric of 04:30:00 hour, which should not be exceeded by the initial time. If it is exceeded, then it should be displayed in red. What I want to do is that in the histogram it would take the actual time and if it is under 4:30 or 4:30, simply show it as actual time in green, but let's say the whole time is 7:30, i would like it to show 4:30 in green and then the rest(overtime) in red in a stacked column chart. Any ideas how to get around this problem? 

First column on the left is the actual time in whole number format and first column from the right is in the same format and it's metric that should not be exceeded

Gediminas12_0-1600694787963.png

This is the following code I use to get my time: 

// Duration formatting 
// * @konstatinos 1/25/2016
// * Given a number of seconds, returns a format of "hh:mm:ss"
//
// We start with a duration in number of seconds
VAR Duration = SUM([Duration])
// There are 3,600 seconds in an hour
VAR Hours = INT ( Duration / 3600)
// There are 60 seconds in a minute
VAR Minutes = INT ( MOD( Duration - ( Hours * 3600 ),3600 ) / 60)
// Remaining seconds are the remainder of the seconds divided by 60 after subtracting out the hours 
VAR Seconds = ROUNDUP(MOD ( MOD( Duration - ( Hours * 3600 ),3600 ), 60 ),0) // We round up here to get a whole number
RETURN
// We put the hours, minutes and seconds into the proper "place"
Hours * 10000 + Minutes * 100 + Seconds
 

So now I've got the histogram looking like that, but that first column, everything over 4:30 should be in red and should display that overtime on it

Gediminas12_0-1600694964413.png

 

 
 
 
 
4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , Not sure I got.

But you can a measure like and use that in conditional formatting with the "Field value" option

Color sales = if(AVERAGE(Sales[Sales Amount])<170,"green","red")

 

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-numbers-in-the-column
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak  This is more with the time and I don't think I can use average value as I need to compare exact valuse against each other, For instance : If time is 7:30 then 4:30 should be shown in green with value shown as 4:30 and then 3 hours shown in red. I believe i would need to create a custom column?

Pragati11
Super User
Super User

HI @Anonymous ,

 

This doesn't help much. Please add more details to your query:

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

@Pragati11 Updated

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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
Top Kudoed Authors