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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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