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.
Hi all, I am trying to create a maps url in power query starting from Lat-Lon data. This works fine in DAX but I am unable to create a calculated column in m. The error I get is that "https:// etc." cannot be converted to type. For reference here below the code for the custom function.
Can you help me?
= (lat,lon) =>
let
A="https://www.google.com/maps/search/?api=1&query=",
B=",",
lat=Number.toText(lat),
lon=Number.toText(lon),
R1=Text.Combine(A,lat),
R2=Text.Combine(R1,B),
Result=Text.Combine(R2,lon)
in
Result
Solved! Go to Solution.
@giogiogio , you might change some statements this way,
R1=Text.Combine({A,lat}),
R2=Text.Combine({R1,B}),
Result=Text.Combine({R2,lon})
or
= (lat,lon) =>
let
A="https://www.google.com/maps/search/?api=1&query=",
Lat=Number.toText(lat), //better with a different variable name to avoid ambiguity
Lon=Number.toText(lon),
Result=Text.Combine({A,Text.Combine({Lat,Lon},",")})
in
Result
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Thanks @CNENFRNL , this fix works great.
Can you please explain me the need for the {} in the code? I thought being both values "text" it was enough. Thanks
@giogiogio , according to the syntax
Text.Combine(texts as list, optional separator as nullable text) as text
the first parameter should be of type list, which means that all substrings to be combined should be populated into a list, e.g. {Lat, Lon}.
Btw, there's a shorthand for Text.Combine when it comes to 2 substrings,
#"Combined Texts" = "A" & "B"
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@giogiogio , you might change some statements this way,
R1=Text.Combine({A,lat}),
R2=Text.Combine({R1,B}),
Result=Text.Combine({R2,lon})
or
= (lat,lon) =>
let
A="https://www.google.com/maps/search/?api=1&query=",
Lat=Number.toText(lat), //better with a different variable name to avoid ambiguity
Lon=Number.toText(lon),
Result=Text.Combine({A,Text.Combine({Lat,Lon},",")})
in
Result
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
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.