Join 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!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hi Team,
I have a scenario where I need to flatten/unpivot Orders and Unit Price columns as Years,Orders,Unit price columns. Please may I have help know how this can be achieved in power query
Solved! Go to Solution.
let
Source = Excel.CurrentWorkbook(){[Name="data"]}[Content],
rows = List.Buffer(Table.ToList(Source, each _)),
years = List.Buffer(List.Range(rows{1}, 3, 3)),
trx = List.TransformMany(
List.Skip(rows, 2),
(x) => List.Zip({years, List.Range(x, 3, 3), List.Range(x, 7, 3)}),
(x, y) => List.FirstN(x, 3) & {x{6}} & {x{10}} & y
),
result = Table.FromList(trx, each _, {"Product", "Prod Cat", "Prod Code", "Sales", "Inv", "Year", "Order", "Unit Price"})
in
result
Here's the solution to your query. It might be a long solution but do have a look.
Hi @han_rj , Could you try these
Unpivot Columns: Select year-based columns, right-click, and choose unpivot columns.
Combine Name & Year: Add a custom column with this formula:
Text.BeforeDelimiter([Attribute], " ") & "_" & Text.AfterDelimiter([Attribute], " ")
Rename & Cleanup: Rename columns as needed and remove unnecessary columns.
If this post helped please do give a kudos and accept this as a solution
Thanks In Advance
Hi Akash, Thanks For the Respose, Please may I have help on the updated request
Could You specify ?
I would like to get an output like this with Year , Sales and Unit sales like this
let
Source = Excel.CurrentWorkbook(){[Name="data"]}[Content],
rows = List.Buffer(Table.ToList(Source, each _)),
years = List.Buffer(List.Range(rows{1}, 3, 3)),
trx = List.TransformMany(
List.Skip(rows, 2),
(x) => List.Zip({years, List.Range(x, 3, 3), List.Range(x, 7, 3)}),
(x, y) => List.FirstN(x, 3) & {x{6}} & {x{10}} & y
),
result = Table.FromList(trx, each _, {"Product", "Prod Cat", "Prod Code", "Sales", "Inv", "Year", "Order", "Unit Price"})
in
result
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 4 | |
| 4 | |
| 3 |
| User | Count |
|---|---|
| 12 | |
| 11 | |
| 7 | |
| 7 | |
| 6 |