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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper III
Helper III

Apply different Background Color for each item in calculation group

Good afternoon,

I created a Calculation group with 9 items. 

I now need to add specific background colors to specific items in the caluculation group.

The first two columns should have background color yellow

Column 3 and 4: Green

Column 5 and 6; Blue

Column 7 and 8: Pink

And colum 9: No background color. 


If tried it using multiple measures, but it doesn't work.

This is one thing I tried:

VAR HuidigeSelectie =
                SELECTEDVALUE ( 'Promodruk'[PromotieCategorie] )
                IF (
                    HuidigeSelectie IN { "Vaste Promo", "Aandeel Vaste Promo" },
                    IF (
                        HuidigeSelectie IN { "FolderPromo", "Aandeel FolderPromo" },
                        IF (
                            HuidigeSelectie IN { "Andere Promo", "Aandeel Andere Promo" },
                            IF (
                                HuidigeSelectie IN { "Niet-Promo", "andeel Niet-Promo" },
                                BLANK ()

 How could I achieve this?

Super User
Super User

Hello @LamSar,


Can you please try this improved DAX:

Background Color Measure = 
        CurrentSelection = "YourCalcGroupItem1" || CurrentSelection = "YourCalcGroupItem2", "#FFFF00",  // Yellow
        CurrentSelection = "YourCalcGroupItem3" || CurrentSelection = "YourCalcGroupItem4", "#008000",  // Green
        CurrentSelection = "YourCalcGroupItem5" || CurrentSelection = "YourCalcGroupItem6", "#0000FF",  // Blue
        CurrentSelection = "YourCalcGroupItem7" || CurrentSelection = "YourCalcGroupItem8", "#FFC0CB",  // Pink
        BLANK()  // No color for Column 9 and others

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website:
➤ Email:
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views):
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

I also tried the manual of SQLBI:


I created a calculated table with the column names of the calculation items. Calculated TableName Promodruk CG Omschrijving. 

Then adjusted the calculation items as follows:

Example of one the items - FolderPromo:

VAR berekening =
        FILTER (
            Promo[IsVastePromo] = 0
                && Promo[PromoCategorie] = "Standaardpromotie"
        'Promodruk CG Omschrijving'[PromotieCategorie] = "FolderPromo"
    IF ( ISSELECTEDMEASURE ( [Dynamic Color CG Promodruk] ), Berekening )

And then I created this measure for the background:

Dynamic Color CG Promodruk:=
VAR Huidigveld =
    SELECTEDVALUE ( 'Promodruk CG Omschrijving'[PromotieCategorie] )
VAR Color =
    SWITCH (
        "Vaste Promo", "Groen",
        "Aandeel Vaste Promo", "Groen",
        "FolderPromo", "Rood",
        "Aandeel FolderPromo", "Rood",
        "Andere Promo", "Geel",
        "Aandeel Andere Promo", "Geel",
        "Niet-Promo", "Blauw",
        "Andeel Niet-Promo", "Blauw",
        BLANK ()

 But it does not return the desired result: I don't get any data back from the calculation group (the matrix is empty) and the color also does not work. 

Good morning Sahir,

This doesn't work. 

When I use this measure nothing happens. 


I added the measure to the matrix to see if it returns the color codes, but it returns the same value of the calculation items itself:



Helpful resources

July 2024 Power BI Update

Power BI Monthly Update - July 2024

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


Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors