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
test_test
New Member

Need to change the background color for alternate rows of country column

Hello folks,

 

I need to change the background color for alternate rows for country column. ex : Canada : Green,  France : Blue, USA : Pink and Germany and Mexico should not change there background color. can anyone help on this. i tried with 

RowColor = IF(MOD([Country_id], 2) = 0, "Green", "Red"), but it is changing to country_id column, my requirement is to change for Country column. pls help

 

test_test_2-1725102802734.png

 

#dax #powerbidesktop

 

2 ACCEPTED SOLUTIONS
PowerBIDave
Regular Visitor

 @test_test 

You could adapt the following to meet your own requirements.

 

1. Select your table visual (step 1)

2. Select the formatting pane (step 2)

3. Expand the "Cell elements" section (step 3)

4. Select "Country" from the Series option (step 4)

5. Turn the "Background color" slider on (step 5)

6. From the "Background color" panel that displays, ensure the "Format style" is set to "Rules" (step 6)

7. Define the background colours you want by defining rules for the requisite countries (step 7)

8. Click the OK button (step 😎

9. Your table should now be formatted as required, as below.

 

Hope that helps.

 

If this answers your question, please mark as a solution so others can find.


PowerBIDave_0-1725104914146.png

 

PowerBIDave_3-1725105688469.png

 

PowerBIDave_4-1725105716867.png

 

View solution in original post

hello @test_test 

 

1. if you want to do with DAX, then create a new measure consist of your requirement.

Color Palette = 
var _Country = SELECTEDVALUE('Table'[Country])
Return
IF(
    _Country="Canada",
    "#00FF00",
IF(
    _Country="France",
    "#0000FF",
IF(
    _Country="United States of America",
    "#FF00AA"
)))

2. as shown by @PowerBIDave , instead of using Rules, use Field Value in Format Style box. Then choose the measure created previously.

Irwan_1-1725154049281.png

 

There you go, it will do conditional formating based on your DAX.

Irwan_0-1725153844626.png

 

Hope this will help.

Thank you.

View solution in original post

3 REPLIES 3
test_test
New Member

Thanks Mate, but it is manual process is there any way to acheive it with DAX ? because here are less rows say i have 20 rows adding rules for 20 rows is a tedious can't we do by dax any. appreicate your help 

hello @test_test 

 

1. if you want to do with DAX, then create a new measure consist of your requirement.

Color Palette = 
var _Country = SELECTEDVALUE('Table'[Country])
Return
IF(
    _Country="Canada",
    "#00FF00",
IF(
    _Country="France",
    "#0000FF",
IF(
    _Country="United States of America",
    "#FF00AA"
)))

2. as shown by @PowerBIDave , instead of using Rules, use Field Value in Format Style box. Then choose the measure created previously.

Irwan_1-1725154049281.png

 

There you go, it will do conditional formating based on your DAX.

Irwan_0-1725153844626.png

 

Hope this will help.

Thank you.

PowerBIDave
Regular Visitor

 @test_test 

You could adapt the following to meet your own requirements.

 

1. Select your table visual (step 1)

2. Select the formatting pane (step 2)

3. Expand the "Cell elements" section (step 3)

4. Select "Country" from the Series option (step 4)

5. Turn the "Background color" slider on (step 5)

6. From the "Background color" panel that displays, ensure the "Format style" is set to "Rules" (step 6)

7. Define the background colours you want by defining rules for the requisite countries (step 7)

8. Click the OK button (step 😎

9. Your table should now be formatted as required, as below.

 

Hope that helps.

 

If this answers your question, please mark as a solution so others can find.


PowerBIDave_0-1725104914146.png

 

PowerBIDave_3-1725105688469.png

 

PowerBIDave_4-1725105716867.png

 

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!

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