Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert a Integer to Text value in Power BI

Tags:

sql

powerbi

dax

m

I am creating a calculated column in existing power BI report. the calculated column concatenates integer & text columns. I tried below query which give syntax error to me,

= Number.ToText(table1.[RegionID]) & " " &  table1.[RegionName]

I tried some other conversion methods which were not a success. Someone please guide me how to achieve the above scenario in power bi

like image 205
bmsqldev Avatar asked Jun 24 '16 09:06

bmsqldev


People also ask

How do I convert a number to text in Power BI?

In the original case here, you'd use =FORMAT([Year], "General Number"] to return a year as a four-digit number, stored as text. Show activity on this post.

How do you convert int to text in DAX?

If you need to do this in the model (for instance, off of a calculated table), the correct DAX would be to use FIXED(<number>,3,1) to convert the number into string at 3 decimals and then RIGHT(<>,3) to retun the right 3 decimals. You can also do the concatenation by “Merge Columns” in Query Editor.

How do I extract text from a cell in Power BI?

Select the column you want to extract the text string from (click on the "Recordno" heading and it should highlight the whole column). Then, in the "From Text" portion of the "Add Column" ribbon, click on "Extract", then "Text Between Delimiters" (see image below).


2 Answers

Make sure you have the correct format string.

Try this:

= FORMAT(table1.[RegionID], "#") & " " & table1.[RegionName]

like image 97
ziviland Avatar answered Sep 20 '22 06:09

ziviland


Try

= "Text" & Number.ToText(Number)
like image 45
Rafael Loureiro Avatar answered Sep 22 '22 06:09

Rafael Loureiro