Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Henrique1993
New Member

LATITUDE E LONGITUDE

Boa tarde, estou com um problema ao importar dados de longitude e latitude do excel para o powerbi.

estou importando uma planilha do excel para o powerbi na qual tenho o lat e o log da seguinte forma:

 


Mas mesmo colocando como decimal no powerbi e classificando como lat e logando no headmap ele não me mostra a localização. porem se eu usar esse mesmo lat e logar no googlemaps esta correto.

 

 

Português:

Boa tarde, estou com um problema na distribuição de dados de longitude e latitude do excel para o powerbi.

estou importando uma planilha de excel para o powerbi no qual eu tenho a lat e log da seguinte forma: (abaixo do texto tem os dados)


Porém mesmo colocando como decimal no powerbi e classificando como lat e log no headmap não me mostra a localização. porém se eu uso essa mesma lat e log no googlemaps está correto.

 

 

 

 

LATITUDE_INICIOLONGITUDE_INICIO
-23.507.488-46.598.988
-23.506.572-46.627.702
-23.506.935-46.627.793
-23.505.707-46.627.672
-23.508.423-46.628.068
-23.506.007-4.662.756
-23.506.442-46.627.653
-23.507.483-4.662.786
-23.506.957-46.627.803
-23.506.023-46.627.645
-23.506.145-46.627.652
-23.506.232-46.627.678
-23.506.807-46.627.813
-23.507.673-46.628.008
-23.508.445-46.628.092
-23.470.058-46.670.642
-23.507.197-46.627.923
-23.469.182-46.670.412
-23.505.877-46.627.722
-2.350.612-46.627.672
-23.506.792-46.627.782
-23.505.837-46.627.622
-23.506.152-46.627.548
-23.470.208-46.670.613
-23.507.223-46.627.963
-23.453.992-46.669.193
-23.453.543-46.671.952
6 REPLIES 6
lbendlin
Super User
Super User

Your source data is in bad shape. You need to transform it into something usable.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZLZDcJADER7yTdYu75dC6L/NjASIR4kPjcv4xkfj8dxZyFbQZp53I67OlklVb+et5P2t+APdQ6KxUBLbNKSQa3/jkE9pjZJWb40aTn6ro+W3JnCHKDqDOU2bd8NyZAmSstmplyCriNTF1YDutXAFmfBAqEC+0mYRW6M7AGzWImTGr5N6/LVWLTs3J/3y5Wh8q7pW3z5qhft5KHVzbC/jKkNPimJtdHmv8v1PgU4m/wpLHAYjNptU2ua0C4vaPdnkAwLLB/tmlBdqd7NF1LTrzZ2H0qner4A", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [LATITUDE_INICIO = _t, LONGITUDE_INICIO = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"LATITUDE_INICIO", type text}, {"LONGITUDE_INICIO", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type",".","",Replacer.ReplaceText,{"LATITUDE_INICIO","LONGITUDE_INICIO"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","-23","-23.",Replacer.ReplaceText,{"LATITUDE_INICIO"}),
    #"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","-46","-46.",Replacer.ReplaceText,{"LONGITUDE_INICIO"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Replaced Value2",{{"LATITUDE_INICIO", type number}, {"LONGITUDE_INICIO", type number}})
in
    #"Changed Type1"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

 

After that the map will work.

lbendlin_0-1644191948661.png

 

Is there a tool that does this? because here I used only one example of a coordinate I have thousands of coordinates and a base with other columns.

 

Existe uma ferramenta que faça isso? pois aqui eu usei apenas um exemplo de uma coordenada eu tenho milhares de coordenadas e uma base com outras colunas.

https://we.tl/t-fGKRw8sxY7

 

I am sending my file that I need to configure these latitudes and longitudes, if you can help me thank you.

 

Estou enviando meu arquivo que preciso configurar essas latitudes e longitudes, se poder me ajudar agradeço.

Assuming that all your latitude and longitude values are negative double digits what you need to do is inject a single period ( or whatever your locale's decimal separator is) at the fourth position of each column. Do not attempt to convert the text into numbers before that.

 

let
    Source = Excel.Workbook(File.Contents("C:\Users\xxx\Downloads\IQF_DEZEMBRO-LIMPO teste.xlsx"), null, true),
    #"Contrato E LAT - LOG_Sheet" = Source{[Item="Contrato E LAT - LOG",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(#"Contrato E LAT - LOG_Sheet", [PromoteAllScalars=true]),
    #"Removed Other Columns" = Table.SelectColumns(#"Promoted Headers",{"LATITUDE_INICIO", "LONGITUDE_INICIO", "LATITUDE_FIM", "LONGITUDE_FIM"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Other Columns",{{"LATITUDE_INICIO", type text}, {"LONGITUDE_INICIO", type text}, {"LATITUDE_FIM", type text}, {"LONGITUDE_FIM", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type",true,"",(o,t,r)=>Text.Start(o,3) & "." & Text.Range(o,3),{"LATITUDE_INICIO","LONGITUDE_INICIO","LATITUDE_FIM","LONGITUDE_FIM"})
in
    #"Replaced Value"

Hi @Henrique1993 if you don't know how to apply the code of @lbendlin you can click 'Transform data' and then right-click on the Latitude and Longitude columns. For each colum, select 'Replace values' from the menu and then replace (one by one):

23. by 23,

46. by 46,

4.6 by 4,6

2.3 by 2,3

. by      (<- so leave blank)

Then change the data type of both columns to 'decimal number' and then it should work. Good luck!

Fiz isso e nada foi alterado no query.

 

Quando clico para ver oque foi feito a alteração aparece apenas os números

 

procurado 46

substituido 46

 

ele ignora o (,) e (.)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.