Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
ajisharavind_99
Advocate I
Advocate I

Pivot or unpivot Multiple Columns

Hi Everyone,  

I am very new to Power Query, and I am looking for a solution to pivot or unpivot data into tabular format.

I believe someone can very quickly help me.

Note: The prgrs break down name will change ID by ID.

Sample Excel file ajisharavind_99_0-1687347731390.png

 

1 ACCEPTED SOLUTION
slorin
Super User
Super User

Hi,

 

= Table.FromRows(
List.TransformMany(
Table.ToRows(Previous_Step),
each {0..6},
(x,y) => {x{0}, x{1+y}, x{8+y}, x{15+y}, x{22+y}, x{29+y}, x{35+y}, x{42+y}}
),
type table [ID = text, Prgrs Breack Down = text, Actual = number, Approved Plan = number, Current Plan= number, Int Plan = number, QPIT VAR = number, Var = number]
)

 

Stéphane 

View solution in original post

4 REPLIES 4
slorin
Super User
Super User

Hi,

 

= Table.FromRows(
List.TransformMany(
Table.ToRows(Previous_Step),
each {0..6},
(x,y) => {x{0}, x{1+y}, x{8+y}, x{15+y}, x{22+y}, x{29+y}, x{35+y}, x{42+y}}
),
type table [ID = text, Prgrs Breack Down = text, Actual = number, Approved Plan = number, Current Plan= number, Int Plan = number, QPIT VAR = number, Var = number]
)

 

Stéphane 

@slorin Thank you very much 🙂 working well , Colud you explain how this code is working (for my understanding)

Hi,

 

Table.ToRows(Previous_Step) 

--> x = each row of Previous_Step (x is a list)

 

each {0..6} 

--> y = 0 ,  y = 1, .... y = 6

 

(x,y) => {x{0}, x{1+y}, x{8+y}, x{15+y}, x{22+y}, x{29+y}, x{35+y}, x{42+y}}

x = first row and  y = 0 

 {x{0} <=> ID, x{1+0} <=> StageDesc1, x{8+0}<=>Actual1, x{15+0}<=>AprvdPlan1 ...}

 

next x = first row and y = 1

{ x{0} <=> ID, x{1+1} <=> StageDesc2, x{8+1}<=>Actual2, x{15+1}<=>AprvdPlan2 ...}

...

List.TransformMany split all rows into 7 lists ( y = 0 to y = 6)

 

and Table.FromRows build a table with this list of list

 

Stéphane

Thank you very much for your time for explaining the code

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors