Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

How to make new columns from values from another column?

Sorry if this has been asked before. I've searched but maybe my wording on my searches isn't finding what I'm trying to accomplish.   I have a set of data and I've created an example to go by and a...
  • _AAndrade's avatar
    2 years ago

    Hi Anonymous,

    I'm attaching a excel file with my solution.
    My M code is this:

    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Name", type text}, {"Question", type text}, {"Answer", type text}}),
        #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Question]), "Question", "Answer")
    in
        #"Pivoted Column"