Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you cast an integer to a string in Excel's PowerQuery

I have a PowerQuery which pulls back two columns; one a Number (an integer), the other Text (a string). I'd like to create a custom column which concatenates these.

It seems this should work: ="(" & ([Value] as text) & ", " & [Description] & ")"

But this returns error Expression.Error: We cannot convert the value 1 to type Text.

NB: This question relates to the PowerQuery editor (i.e. the M language); not regular Excel worksheet functions. The worksheet function to achieve what I'm after would be =concatenate("(", A2, ", ", B2, ")"), where A2 is Value and B2 is Description.

like image 898
JohnLBevan Avatar asked Dec 06 '25 01:12

JohnLBevan


1 Answers

Use the Number.ToText(n) function.

i.e. ="(" & Number.ToText([Value]) & ", " & [Description] & ")"

See https://msdn.microsoft.com/en-us/library/mt253385.aspx?f=255&MSPPError=-2147217396

like image 123
JohnLBevan Avatar answered Dec 11 '25 12:12

JohnLBevan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!