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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
marvicf
Frequent Visitor

Conditional formatting

Hi,

I set up a measure to apply conditional formatting to a table visual according to the measure's value

 

ZoneSelectedWeek = if(ISBLANK(SELECTEDVALUE(Weekly_Extract[WeekNo])),1,2)
 
The measure works correctly, it's value changes whether week no is selected or not
 
Now I'm trying to format the background of a column so that if the measure is 1 background is grey or if measure is 2 background is red
 
My background color format settings
 
marvicf_0-1661430319943.png

The issue is that no matter what value the measure has the background is always red. Tried also with 0 and 1 for measure values but same result

 

Any help pls?

 

Thanks

4 REPLIES 4
Anonymous
Not applicable

Hi  @marvicf ,

I created some data:

vyangliumsft_0-1661931761216.png

Here are the steps you can follow:

1. Create measure.

ZoneSelectedWeek =
IF(
    HASONEVALUE('TWeekly_Extract'[WeekNo]),1,2)
color =
IF(
    [ZoneSelectedWeek]=1,"grey","red")

2. Format – Background – fx.

vyangliumsft_1-1661931761219.png

3. Go to the Color – Effects interface – [color].

vyangliumsft_2-1661931761222.png

4. Result:

Displayed in Gray when selected:

vyangliumsft_3-1661931761224.png

Displayed in red when not selected:

vyangliumsft_4-1661931761226.png

 

If you need pbix, please click here.

Conditional formatting.pbix

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Hi @Anonymous ,

Thanks for your reply.

This works for a card visual but can't get it to work for the background of a table visual column. Column background is set to grey and remains grey whether selected or not

Thanks and regards

amitchandak
Super User
Super User

@marvicf , Try a measure like

 

ZoneSelectedWeek = if(calculate(isfiltered(Weekly_Extract[WeekNo]), allselected() ),2,1)

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

Hi and thanks for your reply

 

Tried the measure you suggested but still no luck. The measure is working fine as I assigned it to a card visual to see its value and when I select the week it's value changes. The issue is that in the table visual the column background is always the color for value 2 and won't change after that

Thanks

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.