The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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.
@Anonymous , 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
@Anonymous , 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! |
@Anonymous , 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! |