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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.