Forum Discussion
Equitable distribution by shorter distance - Geolocation
Hi Dihros
my code, although more concise than yours, it is no more efficient.
try to implement the following scheme if it is acceptable as a solution.
Once the distances matrix has been obtained, having the managers as columns and the distances from the various customers as values, sort by increasing values on the first column (man1, for example) and take the first [customers / man].
remove the first column and the first [customers / man] from the matrix and continue to the last column.
This scheme has the advantage that heavy control operations are performed by functions (therefore with more efficient algorithms and probably faster because they are made in a lower level language)
a script that deals with a table of 1700 customers on 8 managers in 4 locations, in a short time
per scaricarli, fai click sul seguente link e segui le istruzioni.
manTab and clTab are the data tables.
ClientsDistribution the query that produce (using the custom functions provided) the resulting distribution table.
####edit#####
I didn't pay attention to the fact that there were more than ten managers in the data and so I used a formula
Text.End (c, 1) which takes only the last character of the string, so "Manager 1" and "Manager 11" get mixed up.
The following is the correct (and also much simpler) formulation of the function: