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:
- Dihros5 years agoFrequent Visitor
Thank you for your help which I appreciate very much, I was very surprised to see the speed of your code,
While understanding the code I tested it with my test records and noticed that some customer numbers are repeated
It seems to me that they repeat when they have the same distance
I'll keep checking the code,
Thank you so much
Greetings- Anonymous5 years agoNot applicable
Hi Dihros ,
I'm having trouble remembering the details of the last code. I have to find time to look at it again.
Of course it would be better if those who make a request were more punctual in interactions with those who take the trouble to respond.
Can you attach the files with which you do the tests, to have a situation as close as possible to the real one? - Anonymous5 years agoNot applicable
It is not very clear what you mean by the following expression:
"While understanding the code I tested it with my test records and noticed that some customer numbers are repeated"
But if it means what I understand, maybe you should read better the rest of my message, the part following the header #### edit ##### and make the indicated changes to the code
- Dihros5 years agoFrequent Visitor
if i understand well i had done the change in the code already
Also my test data set has only 9 manager in total
What i mean is :
this is the result of your code using my test data set
Checking the data, I found that some IDs are duplicated and which I mark in red,
Taking for example the ID:3100615, it is located in row 287 and 1673 with manager 7 and 8.
I also checked your Table but it doesn't have duplicated. im no sure what's happening