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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
Dicken
Post Prodigy
Post Prodigy

Inserting Rows at given postion in table

Just thought this may be of interest to someone, 
to insert rows at given interals in a tablle, here I have used a list for easy illustration, but just convert table 
to records, and create records to insert in place of null,  the principle is the same , here inserting every 3 rows. 

[
Source = {"A".."Z"} ,
pos = List.Transform({0..25},(x)=> Number.IntegerDivide( x, 3)) ,
result = List.Generate( ()=>
[ x = 0 , y = Source {0} , z = pos {0}, i = {y} ] ,
each [x] < List.Count( Source) ,
each [ x = [x] + 1,   y = Source {x} ,    z = pos {x} ,     i = if [z] = z then {y} else { null, y } ] ,
each [i] ) ,
xp = List.Combine( result )
]


Richard. 

1 ACCEPTED SOLUTION
slorin
Super User
Super User

Hi @Dicken 

 

Add null item every 3 items in a list

 

let
Source = {"A".."Z"},
Result = List.Combine(List.Transform(List.Split(Source, 3), each _ & {null}))
in
Result

 

Add null record every 3 rows in a table

 

let
Source = Table.FromColumns({{"A".."Z"}, {1..26}}),
Null_Table = Table.Buffer(Table.FromColumns({{null}}, List.FirstN(Table.ColumnNames(Source),1))),
Result = Table.Combine(List.Transform(Table.Split(Source, 3), each _ & Null_Table))
in
Result

 Stéphane

View solution in original post

4 REPLIES 4
Dicken
Post Prodigy
Post Prodigy

thank you for you replies, I did like the list transform, method as quite straightforward, 
one thing about my version is it neednt be regular,   so it could be a { 5, 11, 12, 23 .., whatever, 
or  use an actual table column and indert at change   if x[Item] = y [Item] then {y} else { null, y] .
Thanks of help and suggestions.
RD

slorin
Super User
Super User

Hi @Dicken 

 

Add null item every 3 items in a list

 

let
Source = {"A".."Z"},
Result = List.Combine(List.Transform(List.Split(Source, 3), each _ & {null}))
in
Result

 

Add null record every 3 rows in a table

 

let
Source = Table.FromColumns({{"A".."Z"}, {1..26}}),
Null_Table = Table.Buffer(Table.FromColumns({{null}}, List.FirstN(Table.ColumnNames(Source),1))),
Result = Table.Combine(List.Transform(Table.Split(Source, 3), each _ & Null_Table))
in
Result

 Stéphane

v-sdhruv
Community Support
Community Support

Hi @Dicken ,

Thanks for sharing the information. I am sure the community members will benefit from it.
Please accept your answer as solution. This will help the other members find it more quickly.

 

Thank you!!

johnbasha33
Super User
Super User

@Dicken 

let
// Step 1: Create a list from A to Z
Source = {"A".."Z"},

// Step 2: Determine group positions (0-based, every 3 items)
pos = List.Transform({0..25}, (x) => Number.IntegerDivide(x, 3)),

// Step 3: Generate a new list inserting nulls every 3 rows
result = List.Generate(
()=> [x=0, y=Source{0}, z=pos{0}, i={y}],
each [x] < List.Count(Source),
each [
x = [x] + 1,
y = Source{x},
z = pos{x},
i = if [z] = z then {y} else {null, y}
],
each [i]
),

// Step 4: Flatten the list of lists into one
xp = List.Combine(result)
in
xp

Example Output (first few items):

"A", "B", "C", null, "D", "E", "F", null, "G", "H", "I", null, ...
Perfectly adds a null after every 3 items!

Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!



Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.