Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Merge 2 rows as a header

Hi,

 

Can we combine 1 row and 2 row value as header?

Im currently doing it using Transpose but is there any way to merge them without transpose? 

cuz It takes longer modeling process since my data is very heavy. 

 

 

 

e.g. 

As-is

A

B

 

To-be

A|B

  • Hi Anonymous 

    Power Query (PQ) is not a layout tool like Excel but a query logic engine, designed to transform and shape data through defined steps—not to visually manipulate headers or merge cells like in a spreadsheet.

    That means any transformation, even something that looks simple like combining two header rows, requires logical manipulations. Unfortunately, there’s no shortcut for merging row values into column headers without steps like Transpose, Merge, and then Promote Headers.

    In your specific case, since you're trying to merge the first two rows into one header (e.g. A and B to A|B), a Group By won't help, because you're not aggregating by any category—you're just trying to logically stitch two rows together.

    So no, there's no simpler or more efficient way than transposing and re-transforming unless you reshape the source data upstream to already include combined headers.
    There are a few ways to do the transposing, but all of them similar.
    You can tale a look at the linked discussion:
    https://community.fabric.microsoft.com/t5/Desktop/Merge-2-rows-in-one-row/m-p/46144

    Maksim Zelensky shared some really elegant solutions there. I know him personally—he’s one of the strongest Power Query experts out there, globally 🙂

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

     

1 Reply

  • Hi Anonymous 

    Power Query (PQ) is not a layout tool like Excel but a query logic engine, designed to transform and shape data through defined steps—not to visually manipulate headers or merge cells like in a spreadsheet.

    That means any transformation, even something that looks simple like combining two header rows, requires logical manipulations. Unfortunately, there’s no shortcut for merging row values into column headers without steps like Transpose, Merge, and then Promote Headers.

    In your specific case, since you're trying to merge the first two rows into one header (e.g. A and B to A|B), a Group By won't help, because you're not aggregating by any category—you're just trying to logically stitch two rows together.

    So no, there's no simpler or more efficient way than transposing and re-transforming unless you reshape the source data upstream to already include combined headers.
    There are a few ways to do the transposing, but all of them similar.
    You can tale a look at the linked discussion:
    https://community.fabric.microsoft.com/t5/Desktop/Merge-2-rows-in-one-row/m-p/46144

    Maksim Zelensky shared some really elegant solutions there. I know him personally—he’s one of the strongest Power Query experts out there, globally 🙂

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.