Forum Discussion

Jim_PBI's avatar
Jim_PBI
Frequent Visitor
2 years ago

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.

 

 

 

 

 

 

 

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

  • 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.