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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Jim_PBI
Frequent Visitor

DAX code for custom conditional formatting in matrix table

Hello! 

 

I'm attempting to build a matrix table that applies custom conditional formatting on a diverging scale using DAX - see example below. I have tried several iterations of DAX using RANKX with no success.

Matrix table.PNG

 

 

 

 

 

 

 

The visual is grouping by 'Product type' and 'RAG rating' and calculating the count of products in each RAG Criteria / count of products in 'Product type' and RAG rating' excluding the RAG criteria. I would then like to rank these values at row level (in the visual) and apply a custom diverging scale based on the RAG rating colour.

 

An example of the dataset is below

Product typeProductRag criteriaRAG rating
ElectronicsTelevisionTotal IncomeGreen
ElectronicsTelevisionGross MarginGreen
ElectronicsTelevisionOperationalAmber
ElectronicsRadioTotal IncomeGreen
ElectronicsRadioGross MarginGreen
ElectronicsRadioOperationalRed
ElectronicsLaptopTotal IncomeAmber
ElectronicsLaptopGross MarginAmber
ElectronicsLaptopOperationalGreen
ElectronicsSpeakersTotal IncomeGreen
ElectronicsSpeakersGross MarginGreen
ElectronicsSpeakersOperationalGreen
ElectronicsKeyboardTotal IncomeRed
ElectronicsKeyboardGross MarginAmber
ElectronicsKeyboardOperationalGreen
ElectronicsHeadphonesTotal IncomeGreen
ElectronicsHeadphonesGross MarginGreen
ElectronicsHeadphonesOperationalAmber
FurnitureSofaTotal IncomeAmber
FurnitureSofaGross MarginAmber
FurnitureSofaOperationalAmber
FurnitureArmchairTotal IncomeGreen
FurnitureArmchairGross MarginGreen
FurnitureArmchairOperationalAmber
FurnitureBedTotal IncomeAmber
FurnitureBedGross MarginAmber
FurnitureBedOperationalAmber
FurnitureTableTotal IncomeAmber
FurnitureTableGross MarginGreen
FurnitureTableOperationalGreen
FurnitureWardrobeTotal IncomeRed
FurnitureWardrobeGross MarginRed
1 REPLY 1
lbendlin
Super User
Super User

What are you ultimately trying to convey with the report? Your RAD limits seem very arbitrary.

 

Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.