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

Power Query ; Access record field;

 

 

Hi, I have a record,  to insert range to a list; 

 

= [ alist = {1..25} , grupe = 3 , insertN = 2 ,
rc = List.Count( alist) ,
inserts = {"",""} , max = (Number.IntegerDivide(
rc , insertN )*insertN) + rc ,
maxlist = {grupe..max } ,
check = Number.Mod( rc , grupe ) = 0 ,
altlist =
List.Alternate( maxlist, (grupe + insertN ) -1, 1,1) ,
pos = if check = true then List.LastN( altlist,1) else
altlist ,
result = List.Accumulate( pos, alist, (s,c)=>
List.InsertRange( s, c, inserts ) ) ]

 

the problem is i do not seem to be able to access the result field? I   if I put  ie [pos] at end I get that list but [result] = error? 

any suggestions as to why  ? 

Richard. 

 

 

 



1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

inserts = {"",""}

is not doing what you think it does. instead

 

lbendlin_0-1741371612382.png

 

View solution in original post

3 REPLIES 3
Omid_Motamedise
Super User
Super User

The issue is that Power Query records are evaluated lazily, and when you try to access [result], it fails due to how List.Accumulate processes the alist.

Instead of defining the record (rc), define result outside the record structure.

 

let
alist = {1..25},
grupe = 3,
insertN = 2,
rc = List.Count(alist),
inserts = {"", ""},
max = (Number.IntegerDivide(rc, insertN) * insertN) + rc,
maxlist = {grupe..max},
check = Number.Mod(rc, grupe) = 0,
altlist = List.Alternate(maxlist, (grupe + insertN) - 1, 1, 1),
pos = if check then List.LastN(altlist, 1) else altlist,
result = List.Accumulate(pos, alist, (s, c) => List.InsertRange(s, c, inserts))
in
result // Return the evaluated result

 


If my answer helped solve your issue, please consider marking it as the accepted solution.
lbendlin
Super User
Super User

inserts = {"",""}

is not doing what you think it does. instead

 

lbendlin_0-1741371612382.png

 

Thanks, 
I had actually re done and got working, but thank you for taking the time to reply. 

 

RD

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 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.

Top Solution Authors