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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Dicken
Continued Contributor
Continued Contributor

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
Continued Contributor
Continued Contributor

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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 Solution Authors