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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Solution Authors
Top Kudoed Authors