Forum Discussion

cyborgandy's avatar
cyborgandy
Helper II
3 years ago

Matrix Color Formatting

Hi All, I have below dataset.

Compnay NameSpendFiscal YearDepartmentDivison
Water50002022SeaA
Rock100002022ForestB
Salt30002021SeaA
Rock10002022ForestB
Water60002021SeaA
Salt200002022SeaA
Water500002021SeaA
Water500002022SeaA


I have created below matrix in Power bi:

DivisionSea SpendForest SpendTop Company Name In spendSpend Of Top Company
A1340000Water50000
B011000Rock10000


Now I want to do color formatting for Sea Spend and Forest Spend , that if the unique count of company count is below or equal to 2 in that case color the row as green , if more than 2 then red however the unqiue count is not in the matrix , it is availble in the dataset, also under top compnay name i want to show the top company name with highest spend and in Spend table how much they have spend.

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    cyborgandy Maybe:

    Color Flag Measure =
      VAR __Table = DISTINCT('Table'[Company])
    RETURN
      SWITCH(TRUE(),
        COUNTROWS(__Table)=2,1,
        COUNTROWS(__Table)>2,2,
        0
      )

    Use this measure in your conditional formatting based on Rules.