M_M
M_M

Reputation: 501

setting different background color for each row power bi

I created this matrix and I set its value on rows to have this visual : enter image description here

And I want to change the background color of each row according to my customer canvas like this: enter image description here

Is it possible to do that ? bacause I tried formatting condition but it didn't work

Upvotes: 4

Views: 11068

Answers (1)

Przemyslaw Remin
Przemyslaw Remin

Reputation: 6950

Of course it is possible. Add a column with color id to your source table. Say, 1, 2, 3, 4 will be respectively green, yellow, red, blue. Be sure that the color id is a number.

enter image description here

Display your data with table visual. Then, add conditional formatting to each column.

enter image description here

Set it up in this way:

enter image description here

Fields 1-4 enter exactly as they are shown above. I think these settings are self explanatory. Fields 5-6 are up to you. Repeat the row conditional formatting for every column. And you are done:

enter image description here

Here is a sample code to reproduce the source table:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUUosKMhJVYrViVYyAvKSEvOAEMw1BnKTM1KLiirBXBMgNyW1PAkiEAsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column1", "ColorID"}, {"Column2", "Category"}})
in
    #"Renamed Columns"

Upvotes: 3

Related Questions