Forum Discussion

jsteffe's avatar
jsteffe
Icon for Helper III rankHelper III
3 years ago
Solved

Bing map API : how to manage null results ?

I get this custom function that gives the address based on latitude and longitude using the BING MAP API : let FindLoc= (lat, lon) => let Source = Xml.Tables(Web.Contents("http://dev.virt...
  • lbendlin's avatar
    lbendlin
    3 years ago

    That's not DAX, it is Power Query.

     

    let
        FindLoc= (lat, lon) =>
    let
        Source = Xml.Tables(Web.Contents("http://dev.virtualearth.net/REST/v1/Locations/"&Replacer.ReplaceText(Text.From(lat),",",".")&","&Replacer.ReplaceText(Text.From(lon),",",".")&"?o=xml&key=AqXbM3RmYA05LA89D0jBdRSYxgrYNUOwSNEsDS2G9aXaYBqFDOIYDT8IPoHKhJRp")),
        #"Removed Other Columns" = try Table.SelectColumns(Source{0}[ResourceSets]{0}[ResourceSet]{0}[Resources]{0}[Location]{0}[Address],{"FormattedAddress", "Locality"}) 
        otherwise #table({"FormattedAddress","Locality"},{{"undefined","undefined"}})
    in
        #"Removed Other Columns"
    in
        FindLoc