Forum Discussion

VamshiGoud's avatar
VamshiGoud
Frequent Visitor
1 year ago
Solved

Row wise conditional formatting in Matrix Power bi

Hello Friends, I have a requirement where i need to show row wise conditional background color for percentage in Matrix table. For instance :  I have a product column which contains A,B,C and it h...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi VamshiGoud ,

     

    Thanks for audreygerred's solution, that's greate. Since Power BI does not support conditional formatting for rows , as suggested by audreygerred , you may choose between two options: 'using a measure to apply conditional filtering for background color' or 'transposing the table and then creating conditional formatting on the new columns'. Please allow me to add some specific steps to this,

     

    Option1:using a measure to apply conditional filtering for background color

    1\ I assume there is a table -MyTable

    2\Add a new measrue

     

    Measure = SWITCH(TRUE(),
    MAX([Product]) = "A" && MAX([Value]) <= 0.7, "red",
    MAX([Product]) = "A" && MAX([Value]) <= 0.8, "#ffbf00",
    MAX([Product]) = "A" && MAX([Value]) <= 0.9, "Green",
    MAX([Product]) = "B" && MAX([Value]) <= 0.6, "red",
    MAX([Product]) = "B" && MAX([Value]) <= 0.7, "#ffbf00",
    MAX([Product]) = "B" && MAX([Value]) <= 0.8, "Green",
    MAX([Product]) = "C" && MAX([Value]) <= 0.5, "red",
    MAX([Product]) = "C" && MAX([Value]) <= 0.6, "#ffbf00",
    MAX([Product]) = "C" && MAX([Value]) <= 0.7, "Green"
    )

     

    3\Add a matrix table

    4\Set Condition Formatting on Value

    5\Result

    Option2:transposing the table and then creating conditional formatting on the new columns

     

    1\I assume there is a table(Power Query)

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTI3UAWSFmDSEkjG6kQrOcHFzeCyIHFnNHFTkHgsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Product = _t, #"Jan-2024" = _t, #"Feb-2024" = _t, #"March-2024" = _t]),
        #"Demoted Headers" = Table.DemoteHeaders(Source),
        #"Changed Type" = Table.TransformColumnTypes(#"Demoted Headers",{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}}),
        #"Transposed Table" = Table.Transpose(#"Changed Type"),
        #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
        #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Product", type date}, {"A", Percentage.Type}, {"B", Percentage.Type}, {"C", Percentage.Type}})
    in
        #"Changed Type1"
    

     

    2\Set for Sum of A

     

    3\For Sum of B

     

    4\For Sum of C

     

    5\Result

     

    Best Regards,

    Bof