Forum Discussion
distance calculation : optimized route mapquest api
- 6 years ago
Here is some additional instruction
1. Starting with your existing query, group it on the Trip_ID and Start_Location columns, using the Group By button in the ribbon. Call the column "Locations". Choose All Rows as the aggregation.
2. Add a custom column called "ListOfLocations" with this formula - = List.Combine({{[START_LOCATION]}, [Locations][SERVED_LOCATION]})
3. Add a custom column called "ListInQuotes" with this formula - = Text.Combine(List.Transform([ListOfLocations], each """"&_&""""), ", ")
4. Concatenate that new column with the rest of your web call to get your results on each row/for each Trip_ID
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
I wasn't proposing to use OCR as part of the solution. I was just looking to get some example data that matches your real data. Sometimes OCR can be used to extract the data from an image someone provides. In your case, the image was too blurry to do that. Please provide more representative data (either by inserting a table into your reply, or giving a link to an excel file, etc. I will then adapt the M code with the new data.
Regards,
Pat
Hi mahoneypat ,
I not sure I understood what you need to modify your M code. If I sent you a small part of my actual data, would you be able to modify your M code so it would give me what I need for my entire data ?
If not, what do you need exactly ?
Thank you,
Regards,
Marion
- mahoneypat6 years agoMicrosoft Employee
Since your real data has the same column names as your mock data, the M code I provided should actually work. However, I just showed how to turn city names in the column to a text string of names in quotes. You should just need to concatenate that text string with the rest of the URL for the the API call to get it to work. Does that make sense? Have you tried the code I provided on your actual data to see if it makes the text string segment you'll need?
Regards,
Pat
- Anonymous6 years agoNot applicable
mahoneypat,
"However, I just showed how to turn city names in the column to a text string of names in quotes." => yes, it's perfect, that's exactly what I need.
I tried the M code you provided but it gave me text string segments of the mock data from my first post and not of my actual data, even though the column's names are the same. Are you sure that it should work ? Could you modify it so it would work and give me my actual data ?
Thank you,Regards,
Marion- mahoneypat6 years agoMicrosoft Employee
You will need to adapt your real query with the approach I showed in the example. Starting with the #"Grouped Rows" step forward. Once you get the text string of cities, you'll then need to concatenate that string into the longer URL web call to return your results.
Regards,
Pat