Forum Discussion
How to apply multiple colors on a single cell
Hello experts,
Below is the Pivot table view.
I have a requirement to show multiple names belong to a type Type1 as shown below.I need to show them in one cell, I am able to achieve using below measure.
- Anonymous5 years ago
In addition to amitchandak 's reply, conditional formatting can not change names in one cell into different colors.
Here I will give you some advice. Firstly split your names into different cells.
Data model.
Then group all rows by Qtr column and add an index column by M code in Power Query Editor.
... Indexed = Table.TransformColumns(#"Grouped Rows", {{"Rows", each Table.AddIndexColumn(_,"GroupIndex", 1, 1)}}), ...Expand table:
Whole Code in Advanced Editor:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCqksSDVU0lFydASRgYYKRgZGIJahAZAIyizOVorVQahycsKiyj9PIaQoMRlVpaOjMUilEWGVTk5YVGLY7OhoClJlTMh9xKhydDQCqTIhZBYWVQgfxAIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Type = _t, Name = _t, Qtr = _t, Revenue = _t, Status = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Type", type text}, {"Name", type text}, {"Qtr", type text}, {"Revenue", Int64.Type}, {"Status", type text}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Qtr"}, {{"Rows", each _, type table [Type=nullable text, Name=nullable text, Qtr=nullable text, Revenue=nullable number, Status=nullable text]}}), Indexed = Table.TransformColumns(#"Grouped Rows", {{"Rows", each Table.AddIndexColumn(_,"GroupIndex", 1, 1)}}), #"Removed Columns" = Table.RemoveColumns(Indexed,{"Qtr"}), #"Expanded Rows" = Table.ExpandTableColumn(#"Removed Columns", "Rows", {"Type", "Name", "Qtr", "Revenue", "Status", "GroupIndex"}, {"Rows.Type", "Rows.Name", "Rows.Qtr", "Rows.Revenue", "Rows.Status", "Rows.GroupIndex"}), #"Renamed Columns" = Table.RenameColumns(#"Expanded Rows",{{"Rows.Type", "Type"}, {"Rows.Name", "Name"}, {"Rows.Qtr", "Qtr"}, {"Rows.Revenue", "Revenue"}, {"Rows.Status", "Status"}, {"Rows.GroupIndex", "GroupIndex"}}), #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Name", type text}, {"Type", type text}, {"Qtr", type text}, {"Revenue", Int64.Type}, {"Status", type text}, {"GroupIndex", Int64.Type}}) in #"Changed Type1"Then build a matrix, create a color measure and use conditional formatting on Name column.
Name color field = IF(MAX('Sample'[Status]) = "Risk","Red","Orange")Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- AnonymousNot applicable
In addition to amitchandak 's reply, conditional formatting can not change names in one cell into different colors.
Here I will give you some advice. Firstly split your names into different cells.
Data model.
Then group all rows by Qtr column and add an index column by M code in Power Query Editor.
... Indexed = Table.TransformColumns(#"Grouped Rows", {{"Rows", each Table.AddIndexColumn(_,"GroupIndex", 1, 1)}}), ...Expand table:
Whole Code in Advanced Editor:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCqksSDVU0lFydASRgYYKRgZGIJahAZAIyizOVorVQahycsKiyj9PIaQoMRlVpaOjMUilEWGVTk5YVGLY7OhoClJlTMh9xKhydDQCqTIhZBYWVQgfxAIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Type = _t, Name = _t, Qtr = _t, Revenue = _t, Status = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Type", type text}, {"Name", type text}, {"Qtr", type text}, {"Revenue", Int64.Type}, {"Status", type text}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Qtr"}, {{"Rows", each _, type table [Type=nullable text, Name=nullable text, Qtr=nullable text, Revenue=nullable number, Status=nullable text]}}), Indexed = Table.TransformColumns(#"Grouped Rows", {{"Rows", each Table.AddIndexColumn(_,"GroupIndex", 1, 1)}}), #"Removed Columns" = Table.RemoveColumns(Indexed,{"Qtr"}), #"Expanded Rows" = Table.ExpandTableColumn(#"Removed Columns", "Rows", {"Type", "Name", "Qtr", "Revenue", "Status", "GroupIndex"}, {"Rows.Type", "Rows.Name", "Rows.Qtr", "Rows.Revenue", "Rows.Status", "Rows.GroupIndex"}), #"Renamed Columns" = Table.RenameColumns(#"Expanded Rows",{{"Rows.Type", "Type"}, {"Rows.Name", "Name"}, {"Rows.Qtr", "Qtr"}, {"Rows.Revenue", "Revenue"}, {"Rows.Status", "Status"}, {"Rows.GroupIndex", "GroupIndex"}}), #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Name", type text}, {"Type", type text}, {"Qtr", type text}, {"Revenue", Int64.Type}, {"Status", type text}, {"GroupIndex", Int64.Type}}) in #"Changed Type1"Then build a matrix, create a color measure and use conditional formatting on Name column.
Name color field = IF(MAX('Sample'[Status]) = "Risk","Red","Orange")Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- amitchandak
Super User
anileshknpowerb , It is not possible have two color in the same cell