Hi there. I have a content view where I have written Javascript to run through a list of items and aggregate on a field in order to be able to rank the items. In context, I'm running through a list of employee transactions (not-unique) and ranking them by total amount spent. This involves performing a subset sum on all employee transactions and then performing a sort and reverse to get my sorted list which I then use for downstream calculations.
This is all done using for loops which aren't quick and results in the content view taking about 7000ms on a fast machine to load and on slow machines, Omniscope times out and the execution doesn't complete so the content view is blank.
I am not sure how to use the RANK function to do this (if indeed it can) as the docs are a little confusing and there aren't many decent examples. I would like to keep the calculation in the content view if possible.
Please have a look at demo file and detailed explanation in this forum post, dealing with ranking of aggregated values. Not sure that you really need to use JS in the Content View for this, it might be more practical to use formula fields in the Table view or add them in the Field Organiser.