Forum Discussion

Cunial's avatar
Cunial
New Member
8 years ago
Solved

Is it possible to split rows

  Hi All,   I am trying to split a row into several rows with only the value ("Indicator" below) changing.   Here's an example of what I am attempting.     Example:     ID Name Item...
  • MarcelBeug's avatar
    MarcelBeug
    8 years ago

    You can do it in Power Query as illustrated in the video and resulting in the query code below.

     

    Basically Power Query takes care of the steps to have your data properly structured into the datamodel, after which DAX takes over for further modeling and adding measures.

     

    So in my view this should be done in Power Query, but I must admit I'm pretty biased towards Power Query.

    Many people out here would prefer DAX.

     

     

    The query code that was generated during video recording:

     

    let
        Source = Table1,
        #"Added Custom" = Table.AddColumn(Source, "Custom", (ThisRow) => if ThisRow[Name] = "John" then List.Transform({1..Parameter_x},each ThisRow[Indicator]/Parameter_x) else {ThisRow[Indicator]}, type {number}),
        #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
        #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Indicator"}),
        #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Custom", "Indicator"}})
    in
        #"Renamed Columns"