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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Saikumarkatkuri
Frequent Visitor

Need help with Power Query - Creating new rows for non-ending team members

I'm working on a Power Query transformation in Power BI, and I'm facing a challenge that I need assistance with. I have a table with four columns: L0, L1, L2, and L3, representing hierarchical levels in a team structure.

Here is a sample of the original data:

L0 L1 L2 L3 chris damien lucia sai chris damien lucia rashim chris damien rachel
chris edwin
chris lisa mayur
chris lisa mayur geetha

->>> 
let
Source = Table.FromRows({
{"chris", "damien", "lucia", "sai"},
{"chris", "damien", "lucia", "rashim"},
{"chris", "damien", "rachel", null},
{"chris", "edwin", null, null},
{"chris", "lisa", "mayur", null},
{"chris", "lisa", "mayur", "geetha"}
}, type table [L0 = text, L1 = text, L2 = text, L3 = text])
in
Source <----

I want to create new rows for the missing team members, so the table reflects the complete hierarchy. For example, in the above sample data, Lucia and Damien have missing rows in L3, and Lisa is missing in L2, and Chris missing in L0

The desired output should look like this:

L0 L1 L2 L3
chris damien lucia sai
chris damien lucia rashim
chris damien lucia
chris damien
chris edwin
chris lisa mayur
chris lisa mayur geetha
chris lisa
chris


Could someone please guide me on how to achieve this transformation using Power Query? Any insights, suggestions, or sample code would be greatly appreciated.

1 ACCEPTED SOLUTION
slorin
Super User
Super User

Hi

 

= Table.Distinct(
Table.FromRows(
List.TransformMany(
Table.ToRows(Source),
each {1..4},
(x,y) => List.FirstN(x,y) & List.Repeat({null}, 4-y)
),
type table [L0 = text, L1 = text, L2 = text, L3 = text])
)

Stéphane 

View solution in original post

1 REPLY 1
slorin
Super User
Super User

Hi

 

= Table.Distinct(
Table.FromRows(
List.TransformMany(
Table.ToRows(Source),
each {1..4},
(x,y) => List.FirstN(x,y) & List.Repeat({null}, 4-y)
),
type table [L0 = text, L1 = text, L2 = text, L3 = text])
)

Stéphane 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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