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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Ayyappa5678
Helper III
Helper III

Time values with text format and conditional background color format required! Help me pls?

Hi Team,

I have the time values with "00:00" format in table visual(like below snapshot). I need to do conditional formatting like

a) 00:00 to 01:59 with no background color, leave it as it is.

b) 02:00 and remaining all values need to change with background color is red.

I have created a simple measure, setting highlight to yes/no, then do conditional formatting:

HighlightTime =
 var _time = SELECTEDVALUE('Table'[Column1])
 var _highlight =
    IF(
        _time >= TIME(0,0,0) && _time < TIME(2,0,0)  ,
        0// no color
        1 // red color
    )
return _highlight.
Still getting below error. like below snapshot with data type error.

Ayyappa5678_0-1704298705316.png

 

Kindly help me please!
Thanks in advance.

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hey, could you give this a try:
HighlightTime =
VAR _time = SELECTEDVALUE('Table'[Column1])
VAR _timeValue = TIMEVALUE(_time)
VAR _highlight =
IF(
_timeValue >= TIME(0,0,0) && _timeValue < TIME(2,0,0),
0, // no color
1 // red color
)
RETURN _highlight

View solution in original post

v-heq-msft
Community Support
Community Support

Hi  @Ayyappa5678 ,

@Anonymous  nice method!And here's my solution on cell elements format.

Here is my test data:

vheqmsft_0-1704346815390.png

1.Create a measure

 

 

 

 

HighlightTime =
VAR _time =
    TIMEVALUE ( SELECTEDVALUE ( 'Table'[Column1] ) )
VAR _highlight =
    IF ( _time >= TIME ( 0, 0, 0 ) && _time < TIME ( 2, 0, 0 ), 0, 1 )
RETURN
    _highlight

 

 

 

 

2.Formatting cells

Go to Format Visual ->Format your visual

 ->cell elements and apply measure as a function of background color

vheqmsft_2-1704347059039.png

vheqmsft_0-1704347718355.png

 

3.Final output

 vheqmsft_5-1704347215050.png

Best Regards,
Albert He

View solution in original post

5 REPLIES 5
Ayyappa5678
Helper III
Helper III

Thank you so much @Anonymous @v-heq-msft 

Anonymous
Not applicable

No problem at all, happy that we could give a solution 🙂 

v-heq-msft
Community Support
Community Support

Hi  @Ayyappa5678 ,

@Anonymous  nice method!And here's my solution on cell elements format.

Here is my test data:

vheqmsft_0-1704346815390.png

1.Create a measure

 

 

 

 

HighlightTime =
VAR _time =
    TIMEVALUE ( SELECTEDVALUE ( 'Table'[Column1] ) )
VAR _highlight =
    IF ( _time >= TIME ( 0, 0, 0 ) && _time < TIME ( 2, 0, 0 ), 0, 1 )
RETURN
    _highlight

 

 

 

 

2.Formatting cells

Go to Format Visual ->Format your visual

 ->cell elements and apply measure as a function of background color

vheqmsft_2-1704347059039.png

vheqmsft_0-1704347718355.png

 

3.Final output

 vheqmsft_5-1704347215050.png

Best Regards,
Albert He

Anonymous
Not applicable

Thanks! All looks great on the cell formatting too, hopefully this gives the user a solution.

Anonymous
Not applicable

Hey, could you give this a try:
HighlightTime =
VAR _time = SELECTEDVALUE('Table'[Column1])
VAR _timeValue = TIMEVALUE(_time)
VAR _highlight =
IF(
_timeValue >= TIME(0,0,0) && _timeValue < TIME(2,0,0),
0, // no color
1 // red color
)
RETURN _highlight

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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