Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
Hi,
I want to combine excel files in Power Query. I need to pull from each file two rows Revenue and Category. Each file has different categories. Is it possible to tranform the table in this way?
remove "Attribute" column after pivot, not before
Hi,
another solution : Unpivot + Pivot
let
Source = Your_Source,
Unpivot = Table.UnpivotOtherColumns(Source, {"Source", "Type"}, "Attribute", "Value"),
Pivot = Table.Pivot(Unpivot, List.Distinct(Unpivot[Type]), "Type", "Value")
in
Pivot
Stéphane
Hi @slorin
I select "Source" and" Type" column and Unpivot other columns which results in "Attribute" and "Value" column. Now when I select "Type" column--> Transform-->Pivot Column-->selelct "Value"-->"Don't Aggregate-->OK, it works. But if I remove "Attribute" column and then try Pivot, it result in error. When I peek into the error, it says something like this " Expression.Error: There were too many elements in the enumeration to complete the operation.
Details:
[List] "
Can you please elaborate on this error.
Thanks
Hi, @domi25
let
Source = your_table,
f = (tbl) =>
[a = Table.RemoveColumns(tbl, "Source"),
b = Table.Transpose(a),
c = Table.PromoteHeaders(b)][c],
g = Table.Group(Source, {"Source"}, {{"tp", f}}),
expand = Table.ExpandTableColumn(g, "tp", {"Revenue", "Category"})
in
expand
Hi@AlienX
Is this doable in PQ UI. If not can you explain the code, please.
Thanks
Thanks @AlienSx, yes I have seen that video but I was having hard time to digest that code.
@Qasim_Jan Table.Group groups rows of original table by values in Source (to new column "tp") and applies function f to each group of rows. This function itself is simple: removes Source column, transposes (so that Type becomes the first row) and promotes Type to header. Then we expand this
@AlienSx Can't we apply those three operation: Remove Column, Transpose, Promote Header on the main table "Source" instead of defining function for it? Please go easy on me as I am starting in PQ.
@Qasim_Jan no. You can check that yourself and see that this won't work. This set of transformations must be applied to each group of rows. That's why we group them first.