Forum Discussion
Pivoting table?
- 4 years ago
With the original data table, create a matrix visual using Operator name field as rows, PlatformType field as column and add this measure to the Values bucket in the matrix:
DistinctCount of PlatformType = DISTINCTCOUNT (Current Table [PlatformType])
BTW your desired output example doesn't match the original table data. If you want the number of rows for each PlatformType per user use COUNT instead of DISTINCTCOUNT
Hi maciekbala ,
I have done tests and think I can achieve this in power query. Refer to the following steps:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUQoJ9FGK1YlWckJiOwPZfqn5CgbGmRFgARdsAmDVsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [OperatorName = _t, PlatformType = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"OperatorName", type text}, {"PlatformType", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"OperatorName"}, {{"Data", each _, type table [OperatorName=nullable text, PlatformType=nullable text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "TQL", each Table.RowCount(Table.SelectRows([Data], each [PlatformType]= "TQL")), Int64.Type),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Neo", each Table.RowCount(Table.SelectRows([Data], each [PlatformType]= "Neo 03iX")), Int64.Type),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Data"})
in
#"Removed Columns"
If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you, yes it works but as you can see you manually define and create new columns. In my case I need to create them automatically.