Hi,
I need to add an index column to a collection so my in my gallery an item can look into the previous item to hide data if it is the same.
I found this code somwhere here which works but on revieweing the speed of the process that builds the collection this step appears to be incredibly slow (3 seconds for 40 items, a bit less than half the total process that involves getting data from dataverse and sql tables). I don't know why it is is so slow but might someone now a quicker way?
;;ForAll(
Collection1
;Collect(Collection2;
Last(FirstN(AddColumns(Collection1;
"SortNr";
CountRows(Collection2)+1
);
CountRows(Collection2)+1
)
)
)
)
Solved! Go to Solution.
Any time you use a ForAll table creating function to act like a ForLoop, you will experience performance issues.
The formula should be the following:
ForAll(Sequence(CountRows(Collection1));
Patch(Last(FirstN(Collection1; Value)); {SortNr: Value})
)
This will return a table with all of your rows of collection1 and an added column with the row number.
I hope this is helpful for you.
Any time you use a ForAll table creating function to act like a ForLoop, you will experience performance issues.
The formula should be the following:
ForAll(Sequence(CountRows(Collection1));
Patch(Last(FirstN(Collection1; Value)); {SortNr: Value})
)
This will return a table with all of your rows of collection1 and an added column with the row number.
I hope this is helpful for you.
Thanks! That helps!!
For anyone copy pasting in europe: the , after "FirstN(Collection1" should be an ; of course
I tried to remember to replace commas with semi's...forgot one! I have changed it in the posted formula.
Glad to help.
Hi @RandyHayes
I tried your code but its not working as expected
App OnStart Code:
ClearCollect(MeetingDetailsCol, MeetingDetails);
ForAll(Sequence(CountRows(MeetingDetailsCol));
Patch(Last(FirstN(MeetingDetailsCol, Value)), {SortNr: Value})
)
I cant see any Index Column in my collection any help?
User | Count |
---|---|
124 | |
87 | |
86 | |
75 | |
69 |
User | Count |
---|---|
214 | |
181 | |
140 | |
96 | |
83 |