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
giogiogio
Helper II
Helper II

Concatenate texts in m - with special characters (?)

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

 

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

@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!

View solution in original post

3 REPLIES 3
giogiogio
Helper II
Helper II

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!

CNENFRNL
Community Champion
Community Champion

@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!

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.

Top Solution Authors
Top Kudoed Authors