Forum Discussion
How to add multiple rows in to get data from an external source via an API
- 2 years ago
1.) use this code for fnGetDistance (this one is significantly faster)
(start as text, end as text)=> let Source = Json.Document(Web.Contents("https://distance.geoportail.lu/webservice/" & start & ":" & end & "?format=json")), Calculated = Source[calculated] in Calculated2.) now I see the error for Output query -
Now we have two options:
a.) you have to turn off the firewall (you need to do this for every user who will use this query)b.) replace whole code for Output query with this one:
let Source = Excel.CurrentWorkbook(){[Name="t_EnteredPoints"]}[Content], FilteredRows = Table.SelectRows(Source, each not List.Contains({[startpoint], [endpoint]}, null)), Ad_Distance = Table.AddColumn(FilteredRows, "distance", each fnGetDistance([startpoint], [endpoint]), type number), ChangedType = Table.TransformColumnTypes(Ad_Distance,{{"startpoint", type text}, {"endpoint", type text}}) in ChangedTypewith this b.) option you will need to few times to click IGNORE privacy:
Hi, you can enter multiple points and click refresh on Calculated Distance. (See attached .xlsx file)
Hello,
Thank you for your reply.
My objective is to have a calculated distance on each row based on the corresponding start and endpoint in that same row, like in the picture below:
Like this, my colleagues can enter multiple travels (in each row) for the complete month.
I can not extend the table range of the Distance cells. After each refresh, the table returns to the single cell value only.
Thank you again for your advice.
Best regards.
- dufoq32 years agoCommunity Champion
Check attached file
- Phil2252 years agoRegular Visitor
Thank you, I will try to understand how this works and see if I can add new start/endpoints in the table with the distance being calculated via the API.
Would it be okay if I ask again in case I do not understand how this is done?
Best regards.
- dufoq32 years agoCommunity Champion
You're welcome. Of course you can add new start/endpoints 😉 Let me know if you have questions.