I was doing a simple operation. That is, I have a list of numbers, and I want to insert an empty value/null at certain indices. however, I get a weird result as shown in the screenshot.
Also, you’ll see that I did it in a weird way that I consider not smart and not fully parametric, but at least it gets the job done and The resulting list is exactly what I want. However, in my original case, since I want to insert an item at a large number of indices, the process is not going to be efficient.
My question is, why is the Insert Items not behaving as I expect?, and is there a way to do what I expect smarter than I did?
I’m looking for a formula or an expression that could adjust an input of a list of indices, so the output would be the adjusted/right indices and that would help to get what I want (the expected result as shown in the screenshot). Is that possible?
Actually, I want the result list to be increased, no problem with that. I want to match it with another list, so eventually, the list I want to adjust will have the same amount of items as the other list. That’s because I’m trying to export them to Excel, and you know, all lists should have the same number of items \ same length.
So, inserting Empty values where I want, like indices (3,8,5 and there are a lot more than these) will get the job done properly.
Here’s the proof of my actual scenario using your subtraction-based approach. I have a list of generated indices. These indices will be inserted into a specific list as “-”, that means they will increase the number of items in order to reach a total of 122 items. As you can see in the screenshot, the resulted list is exactly 122 and the indices were exactly in place.
I made a closer look to the end of the list, but the rest of the indices are all good. Thanks again.
ok, I thought about that for 10 minutes with a good drink
the issue stems from the thing that with List Items you specify the insertion index, not the final index of the inserted items
so -of course- if you want to end.up with something at indexes 3, 5, 8 you have to account for the other items in the list to slide one position at each insertion
for instance, base list 0 to 9
if you say “I want to add items at 3, 5, 8” then Insert Items works exactly as expected:
if was enlighting to look at that with this intermediate step (which is pure text edited by hand) where the nulls are actually placed into the list at the right location, but of course two items can’t have same index so each of them slide one position:
but again, Insert Item using Multiple Indices just does behave as expected you just need to input the insertion index, not the final index of the inserted items