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:
Ok, replace whole code of fnGetDistance with one of this codes in advanced editor and let me know (I would prefer v1)
v1
(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
Calculated
v2
(start as text, end as text)=>
let
Source = Web.Page(Web.Contents("https://distance.geoportail.lu/webservice/" & start & ":" & end & "?format=string")),
Data0 = Source{0}[Data],
Children0 = Data0{0}[Children],
Children1 = Children0{1}[Children],
ChangedType = Table.TransformColumnTypes(Children1,{{"Text", type number}}, "en-US"),
Text = ChangedType{0}[Text]
in
Text
I replaced your code and here is the result:
I will be in a meeting now until the end of the day. It's great that you keep helping me, this is well appreciated. Enjoy your weekend and I'll look forward starting my PQ course next week.
Thank you again for your time !
- dufoq32 years agoCommunity Champion
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: