Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Obtengo esta función personalizada que proporciona la dirección basada en latitud y longitud usando la API DE MAPA DE BING:
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")),
#"Type modifié" = Table.TransformColumnTypes(Source,{{"Copyright", type text}, {"BrandLogoUri", type text}, {"StatusCode", Int64.Type}, {"StatusDescription", type text}, {"AuthenticationResultCode", type text}, {"TraceId", type text}}),
#"ResourceSets développé" = Table.ExpandTableColumn(#"Type modifié", "ResourceSets", {"ResourceSet"}, {"ResourceSets.ResourceSet"}),
#"ResourceSets ResourceSet" = #"ResourceSets développé"{0}[ResourceSets.ResourceSet],
#"Type modifié1" = Table.TransformColumnTypes(#"ResourceSets ResourceSet",{{"EstimatedTotal", Int64.Type}}),
Resources = #"Type modifié1"{0}[Resources],
Location = Resources{0}[Location]
in
#"Location"
in
FindLoc
Funciona bien, pero si mi punto GPS está en el océano, no hay valor devuelto y genera un error.
¿Cómo puedo resolver este problema?
Gracias por su ayuda,
Jérôme
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")),
#"Type modifié" = Table.TransformColumnTypes(Source,{{"Copyright", type text}, {"BrandLogoUri", type text}, {"StatusCode", Int64.Type}, {"StatusDescription", type text}, {"AuthenticationResultCode", type text}, {"TraceId", type text}}),
#"ResourceSets développé" = Table.ExpandTableColumn(#"Type modifié", "ResourceSets", {"ResourceSet"}, {"ResourceSets.ResourceSet"}),
Location = try #"ResourceSets développé"{0}[ResourceSets.ResourceSet]{0}[Resources]{0}[Location][Name]{0} otherwise "undefined"
in
#"Location"
in
FindLoc
Gracias por su respuesta que funciona perfectamente.
Pero quiero obtener 2 columnas (lacationName y AdressLocality, por ejemplo), ¿debo crear 2 funciones (una para cada información) o puedo devolver 2 columnas (o una tabla) como resultado de mi función?
Sí, puede modificar mi propuesta para devolver una tabla en lugar de un valor escalar.
Como nunca antes usé funciones Dax, ¿podría darme la sintaxis completa que debería usar en mi función, por favor?
Muchas gracias.
Eso no es DAX, es 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
¡Muchas gracias por su ayuda, que fue muy útil!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |