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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Lolo_2023
Frequent Visitor

How to Add Icons in a Table Matching Slice Colors in a Pie Chart

Hi everyone,

 

I’m working on a Power BI report that includes a pie chart and a table. I’d like to add a column in the table that contains icons, and I want the color of these icons to match the corresponding slice colors in the pie chart.

 

Does anyone know how I can achieve this? Are there specific DAX expressions or formatting settings that I should use?

pie chart with table.png

2 ACCEPTED SOLUTIONS
Tahreem24
Super User
Super User

@Lolo_2023 

Workaround 1: Yes you can format the color of these icons with the help of condition formatting option. First click on the column name on which those icons are displaying then "Condition FOrmatting" option and then "Icons" and then select them as per your wish.

 

Tahreem24_0-1734507329089.png

Tahreem24_1-1734507452365.png

 

 

Workaround 2: With the help of DAX Measure you can manage the color.

 

Color Measure = SWITCH( TRUE(),
                                           Table[Column] = "your condition", "Paste HexColor code here",
                                            Table[Column] = "your condition", "Paste HexColor code here",

                                            so on ......
)

Then use this measure to on condition formatting as Font Color.

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

danextian
Super User
Super User

@Lolo_2023 

Not with the default icons. Use  a measure that returns SVG images and use that in conditional formatting still as icons. The colors and shapes depend on certain conditions. 

Conditional Icon = 
VAR ShapeType =
    SWITCH (
        TRUE (),
        [% to Subtotal] > 0.3, "Square",
        [% to Subtotal] > 0.1, "Diamond",
        "Circle"
    )
VAR FilColor =
    SELECTEDVALUE ( 'Table'[Color] ) -- Dynamic color from the table
VAR StrokeWidth = 2 -- Set to 0 to remove the borders
RETURN
    SWITCH (
        ShapeType,
        "Circle",
            "data&colon;image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'> 
        <circle cx='50' cy='50' r='40' style='fill:" & FilColor & ";stroke-width:" & StrokeWidth & ";stroke:rgb(0,0,0)' /> 
        </svg>",
        "Square",
            "data&colon;image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'> 
        <rect x='10' y='10' width='80' height='80' style='fill:" & FilColor & ";stroke-width:" & StrokeWidth & ";stroke:rgb(0,0,0)' /> 
        </svg>",
        "Diamond",
            "data&colon;image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'> 
        <polygon points='50,10 90,50 50,90 10,50' style='fill:" & FilColor & ";stroke-width:" & StrokeWidth & ";stroke:rgb(0,0,0)' /> 
        </svg>",
        -- Default case: SVG with zero dimensions
        "data&colon;image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='0' height='0'></svg>"
    )

Note: the code gets messed up after hitting reply. Working code is in the attached pbix. SVG generated with the help of ChatGPT.

danextian_0-1734510331848.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

8 REPLIES 8
v-karpurapud
Community Support
Community Support

Hi @Lolo_2023 

Thanks for reaching out to the Microsoft Fabric Community Forum.
To add a column with icons in a table and match their colors to the corresponding slice colors in a pie chart, follow these steps:
1.Define Colors with DAX: Create a DAX column or measure (e.g., Category Color) that assigns specific hex color codes to each category.

DAX

Category Color =

SWITCH(

    TRUE(),

    'Table'[Category] = "Category A",  (Sample hexcode”FF5733"),

    'Table'[Category] = "Category B",  "#33FF57",

    'Table'[Category] = "Category C",  "#3357FF",

    "#000000" ---Hex code for default color.

)
2. Under Conditional Formatting, select Icons. In the dialog box, Set rules or measures to display icons based on your logic (e.g., "Positive → Green Arrow," "Negative → Red Arrow").
3. Apply Background Color or Font Color conditional formatting to match the color defined in the Category Color .

 

If you have any further questions or need additional help with this, feel free to reach out     to us for further assistance!

If you find this post helpful, please mark it as an "Accept as Solution" and give a KUDOS.




But OP was asking for conditionally formatting the icon color and not that of the font or the background.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @Lolo_2023 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

Hi @Lolo_2023 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution we provided for your issue worked for you  or let us know if you need any further assistance?

 

Your feedback is important to us, Looking forward to your response. 

 

Hi @Lolo_2023 
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.

danextian
Super User
Super User

@Lolo_2023 

Not with the default icons. Use  a measure that returns SVG images and use that in conditional formatting still as icons. The colors and shapes depend on certain conditions. 

Conditional Icon = 
VAR ShapeType =
    SWITCH (
        TRUE (),
        [% to Subtotal] > 0.3, "Square",
        [% to Subtotal] > 0.1, "Diamond",
        "Circle"
    )
VAR FilColor =
    SELECTEDVALUE ( 'Table'[Color] ) -- Dynamic color from the table
VAR StrokeWidth = 2 -- Set to 0 to remove the borders
RETURN
    SWITCH (
        ShapeType,
        "Circle",
            "data&colon;image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'> 
        <circle cx='50' cy='50' r='40' style='fill:" & FilColor & ";stroke-width:" & StrokeWidth & ";stroke:rgb(0,0,0)' /> 
        </svg>",
        "Square",
            "data&colon;image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'> 
        <rect x='10' y='10' width='80' height='80' style='fill:" & FilColor & ";stroke-width:" & StrokeWidth & ";stroke:rgb(0,0,0)' /> 
        </svg>",
        "Diamond",
            "data&colon;image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'> 
        <polygon points='50,10 90,50 50,90 10,50' style='fill:" & FilColor & ";stroke-width:" & StrokeWidth & ";stroke:rgb(0,0,0)' /> 
        </svg>",
        -- Default case: SVG with zero dimensions
        "data&colon;image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='0' height='0'></svg>"
    )

Note: the code gets messed up after hitting reply. Working code is in the attached pbix. SVG generated with the help of ChatGPT.

danextian_0-1734510331848.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Tahreem24
Super User
Super User

@Lolo_2023 

Workaround 1: Yes you can format the color of these icons with the help of condition formatting option. First click on the column name on which those icons are displaying then "Condition FOrmatting" option and then "Icons" and then select them as per your wish.

 

Tahreem24_0-1734507329089.png

Tahreem24_1-1734507452365.png

 

 

Workaround 2: With the help of DAX Measure you can manage the color.

 

Color Measure = SWITCH( TRUE(),
                                           Table[Column] = "your condition", "Paste HexColor code here",
                                            Table[Column] = "your condition", "Paste HexColor code here",

                                            so on ......
)

Then use this measure to on condition formatting as Font Color.

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Kedar_Pande
Super User
Super User

@Lolo_2023 

Add a column to your dataset with hex codes or color names that correspond to the pie chart slice colors.

Under Conditional Formatting, apply Font Color or Background Color and base it on the custom color field.

 

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors