Converting an Integer to a Text Value in Power Bi
I’m Creating a Calculated Column in a Power Bi Report. the Calculated Column Concatenates Integer and Text Columns. I Tried Using the Below Query to Accomplish...
I’m creating a calculated column in a Power BI report. The calculated column concatenates integer and text columns. I tried using the below query to accomplish this, but it resulted in a syntax error.
CalculatedColumn = Number.ToText(table1.[RegionID]) & " " & table1.[RegionName]
I tried some other conversion methods also, which were not successful. Could someone please guide me on how one could achieve the above objective in Power BI?
6 Answers
Try
= "Text" & Number.ToText(Number)
Make sure you have the correct format string.
Try this:
= FORMAT(table1.[RegionID], "#") & " " & table1.[RegionName]
You must use the function format. The first argument is the value itself, and the second one is the format you want. Use "string", like the code below:
=FORMAT([RegionID], "string") & " " & [RegionName]
=FORMAT(numeric_value, string_format) recognises nine formats for the second argument of =FORMAT(), where the type of string format is specified. The 0tri0g error referred to above arises because string itself isn't one of the nine formats. You can see the full list here: .
In the original case here, you'd use =FORMAT([Year], "General Number"] to return a year as a four-digit number, stored as text.
I have created the calculated column as below without any explicit conversion:
Region = table1.[RegionID] + " " + table1.[RegionName]
You can use the FORMAT keyword as stated the the above comments.
Just make sure if concatenating strings, use the '&' not '+'. If you still get errors, use format.
Region = FORMAT(table1.[RegionID], "#") & " " & table1.[RegionName]
You can use "string" instead of "#" too.