Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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.
Solved! Go to Solution.
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
inserts = {"",""}
is not doing what you think it does. instead
Thanks,
I had actually re done and got working, but thank you for taking the time to reply.
RD
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 9 | |
| 7 | |
| 6 |