Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Merge multiple rows with alternating null values in Power BI

Hello,   This is the data I have currently. I am trying to merge every 3 rows for each customer order. Because all cell values are the same for each order's aa to ee, I would like the data to be cl...
  • BITomS's avatar
    2 years ago

    Hi Anonymous ,

     

    You can use the Group By functionality. You can find this either on the transform tab of Power Query, or right click on a column header and select 'Group By' from the list.

     

    You will then need to select 'Advanced' and use your aa to ee columns as the groupings, and create aggregations for your years columns (I think SUM operation is appropriate for your use case). For example:

     

    Hope this helps!

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

     

    Your solution is great, BITomS . Here I have another idea in mind, and I would like to share it for reference.

     

    You can create a new table and use the DAX code as follows:

     

    CalculatedTable =
    SUMMARIZE(
        OriginalTable,
        OriginalTable[cc],
        "aa", MAX(OriginalTable[aa]),
        "bb", MAX(OriginalTable[bb]),
        "dd", MAX(OriginalTable[dd]),
        "ee", MAX(OriginalTable[ee]),
        "2020", MAX(OriginalTable[2020]),
        "2021", MAX(OriginalTable[2021]),
        "2022", MAX(OriginalTable[2022])
    )

     

    A new table CalculatedTable is created, and the result is as follows:

     

     

    If you have any other questions please feel free to contact me.

     

    Best Regards,
    Zhu
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!