Forum Discussion
tockert
4 years agoRegular Visitor
Count across multiple columns
I have a table with multiple team members shirt style (Men or Women) and shirt size. 5 different rows for each one of the above, and they are named like this. TM#1_Shirt_Style, TM#1_Shirt Size......
- Anonymous4 years ago
Hi tockert ,
According to your screenshot, I create a sample to have a test. Here I suggest you to transform your table in Power Query Editor, then you can get result by creating a matrix visual.
M code:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZZBLDoAgDETv0jWXEBHlt9aEsHSp3n8nHyMtXRAyvOl0QowwgYD9uc473z6fokNVh4ckIsz4QYDs8jOoIaEPhMrlwBVL2P6XwhfGNa2gUWBbsZIRgXTjOLIa8MZiMKSBgeEPLMGWFXS0oBvnPeWeBQRqIDKlFw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Team Member #2 Name" = _t, #"Team Member #2 Shirt Style" = _t, #"Team Member #2 Size" = _t, #"Team Member #3 Name" = _t, #"Team Member #3 Shirt Style" = _t, #"Team Member #3 Size" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Team Member #2 Name", type text}}), #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type), #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Index", {"Index"}, "Attribute", "Value"), #"Duplicated Column" = Table.DuplicateColumn(#"Unpivoted Other Columns", "Attribute", "Attribute - Copy"), #"Extracted First Characters" = Table.TransformColumns(#"Duplicated Column", {{"Attribute", each Text.Start(_, 14), type text}}), #"Extracted Text Range" = Table.TransformColumns(#"Extracted First Characters", {{"Attribute - Copy", each Text.Middle(_, 15, 100), type text}}), #"Pivoted Column" = Table.Pivot(#"Extracted Text Range", List.Distinct(#"Extracted Text Range"[#"Attribute - Copy"]), "Attribute - Copy", "Value"), #"Sorted Rows" = Table.Sort(#"Pivoted Column",{{"Attribute", Order.Ascending}, {"Index", Order.Ascending}}), #"Removed Columns" = Table.RemoveColumns(#"Sorted Rows",{"Index"}) in #"Removed Columns"New Table:
Then create a matrix and get result directly.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
tockert
4 years agoRegular Visitor
Here is a snip of the table from Excel that I import into Power BI.
Trying to count all of the different sized shirts by men or women.
Thanks