Forum Discussion

ChemEnger's avatar
ChemEnger
Advocate V
2 years ago
Solved

Create table from columns, defined from SelectRows

I have a table of Results by Analyst and would like to run an ANOVA in Excel.  I am using Power Query to split the data into separate columns by Analyst: let Source = Table.FromRows(Json.Docume...
  • p45cal's avatar
    2 years ago

    How about doing without the function and using Group By in the Transform tab instead, grouping on the Analyst column:

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jZNLDoMwDESvUrGuEAkUnGXLroBUUcQGcf9rVCKfeoITscvTOHE8treteE/FvVCmpGK/O9JVWadImdS51IyoRE0dNH15roN0BYpJxZ00c/GNc1w/jVayZa2DpQ6IMtRCgkagkMJIGQN2DOPP2ZTP/i8JZ/fg+OHJZSJBey2WHkC1QMKUhHue0EAFVF+mRrB6HW52qFDU8FEFxDU/jE5j/SLoJbkSPBmBsFg0Qp6InIbUZu7hKnTCK/4vrbCUclMUNxfL430m2GyDZqLtYDqdFGluCKyMCefNFjov/I8Hua2YoflCXMiNFJYuwiaL+eBIBTOiFZPm2PdWJycyF2nwvP8A", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Analyst = _t, Result = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Result", type number}}),
        GroupedRows = Table.Group(#"Changed Type", {"Analyst"}, {{"grp", each _[Result]}})[grp],
        Headers = List.Transform({1..List.Count(GroupedRows)}, each Number.ToText(_,  "Analyst 0")),
        Finish = Table.FromColumns(GroupedRows, Headers)
    in
        Finish

     

    The GroupedRows step returns only the [grp] column of the grouped tables, which makes it a list.