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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
PrivateAnalytic
Helper IV
Helper IV

Formatting color in a Dax formula

Out of curiosity are you able to conditionally format values that are formatted like 0:00:00? I'm looking to format things that are above 15 minutes. I tried including a color VAR in my DAX Formula to format it. So what I added was the VAR color and the & IF statement. It seemed to have worked, however instead of making the values red, it added the #ff0000" at the end of those that were above 15 minutes.

 

Avg Response Time (Mins) = VAR hours = ROUNDDOWN( 'ReadTime'[AvgResponseTime] / 3600,0) VAR minutes = ROUNDDOWN( MOD( 'ReadTime'[AvgResponseTime], 3600) / 60, 0) VAR seconds = INT( MOD ('ReadTime'[AvgResponseTime], 60) ) VAR color = "0:15:00" RETURN FORMAT(hours, "0") & ":" & FORMAT(minutes, "00") & ":" & FORMAT(seconds, "00") & IF(minutes > 15, "#ff0000", BLANK())

5 REPLIES 5
v-yalanwu-msft
Community Support
Community Support

Hi, @PrivateAnalytic ,

please provide some sample data in your tables (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.

https://community.powerbi.com/t5/Desktop/How-to-upload-PBI-in-Community/m-p/1672886


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-yalanwu-msft
Community Support
Community Support

Hi, @PrivateAnalytic ;

You could create a column as follows:

Time in Text = 
VAR Seconds =[Column1]
VAR Minutes =
     INT(MOD(Seconds,3600)/60)
VAR Hours =
    INT(Seconds/3600)
VAR ss =
    MOD(MOD(Seconds,3600),60)
RETURN
    Hours & ":" & Minutes & ":" & ss

The final show:

vyalanwumsft_0-1655805751703.png

Then create a conditional measure.

Measure = IF(INT(MOD(MAX('Table (2)'[Column1]),3600)/60)>15, "#ff0000","black")

vyalanwumsft_1-1655805798829.pngvyalanwumsft_2-1655805807824.png

The final show:

vyalanwumsft_3-1655805819600.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello! @v-yalanwu-msft Provided is a screenshot of what what I'm using, measures created, and the end goal. I attempted creating a column and measure you provided however it didn't seem to work right

PrivateAnalytic_0-1655833641299.png

 

Greg_Deckler
Super User
Super User

@PrivateAnalytic You should be able to use conditional formatting rules to do this.

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

I do try to do that, however when I try to click on the conditional formatting, and select the field, it blurs out the field. It is an already created calculation, so that is why I am trying to use dax to color.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors