AutoPopulating Rows using RandomItem resulting in duplicates

I have a fairly complex ModifyRows action that is intended to populate a cell with information from another table based on a couple of factors. Everything is working well except for one factor that seems to only result in a mistake because (and this is an assumption) the push buttons is moving too fast.

Essentially the action should fill each cell in a column with a RandomItem from a table that meets certain criteria AND is not already in the column. So as the push button goes down the column it should be checking cells it just populated and not using the same number. Unfortunately I still get duplicates on occasion and I am not entirely sure what I am doing wrong or if there is a way to avoid it.

ModifyRows(thisRow, [Daily Tracker 2].Van, if(and(not(thisRow.[Last Van].In([Daily Tracker 2].Van)),thisRow.[Last Van Grounded]=false),thisRow.[Last Van], RandomItem(Vehicles.Filter(and(Grounded=false, not([SDTO #].In([Daily Tracker 2].Van,not([SDTO #].in([Daily Tracker 2].[Last Van])))))),false) ))

1 Like

i am not sure if this applies to your logic (i have not fully understood it) BUT…

i have found that the order in which columns are set inside a modifyrows() function which has multiple assignments, is not always the same order as they are written.

often this has no impact, as the assignments are totally independent.

BUT…

if (for example) the SECOND assignment depends on the FIRST assignment having been completed, THEN you will observe some unexpected behavior.

SO…

i have sometimes had to code TWO or more ModifyRows() inside a RunActions() block in order to be certain that the columns are set in the correct sequence.

maybe THIS is the problem?

respect
max

1 Like

Thanks! Made two changes. Instead of checking if a number exists in the column I added a step to the modify rows to check a box in the table I am pulling from to say it is “in use” then I filter out " in use = true" the combination of RunActions and this change seems to have worked. Appreciate you reaching out!

1 Like