Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

DAX function for converting a number into a string?

I have a string (url) and a number (pagination), I need to concatenate them into a resulting URL. 

 

I have search and looked at the VALUE and FORMAT dax functions but can't make it work in converting a number into a string. e.g.

 

"http://www.xyz.com?page=" & [page] 

returns an error  "We cannot apply operator & to text and number. 

 

Any clues how I can convert [page] to a string?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks, ended up using Text.From( [Counter] )

View solution in original post

11 REPLIES 11
omikeyz
Frequent Visitor

All I did was to create a new column

1 Material_T = Materials[Material] 
and I formatted that field as a text. Then I can use the search Text in my visuals rather than using a filter for 50,000 numbers. it works fine. 
Anonymous
Not applicable

Yes, this is easy to pull off in Power Query.  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. 

v-haibl-msft
Employee
Employee

@Anonymous

 

You can also do the concatenation by “Merge Columns” in Query Editor. Select these two columns and click “Merge Columns”.

DAX function for converting a number into a string_1.jpg

 

Best Regards,

Herbert

= "Text" & Number.ToText(Number)

Wow, That's pretty easy. 

Thanks

CheenuSing
Community Champion
Community Champion

@Anonymous

 

try using 

"http://www.xyz.com?page=" & Format([page] ,"####")

 

If this works please accept as a solution and also give Kudos. If it does not work let me know what happened.

 

Cheers

 

 

 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

This should be the solution, because the request was to use DAX, not Power Query M.

Anonymous
Not applicable

Thanks, ended up using Text.From( [Counter] )

Format() is the correct answer. What you've used is not DAX

Anonymous
Not applicable

HOw to you use this FORMAT() function in example?

lets say if you have two columns where you are appling into  a meaure 

ie 

newmeasure = viewname[columnnameingar] and  viewname[newcolumnstring] , "a stringvalue"

Not sure I'm fully understanding you @Anonymous

 

General info page on FORMAT: https://docs.microsoft.com/en-us/dax/format-function-dax

 

Couple examples from: https://docs.microsoft.com/en-us/dax/pre-defined-numeric-formats-for-the-format-function

FORMAT( 12345.67, "General Number")

FORMAT( 12345.67, "Currency")

 

FORMAT( 12345.67, "Percent")

 

Combining column values in a measure usually won't work due to context. Unless you first aggregate the columns in some way. Measures yield a single value given a context, so if your context includes multiple rows, then any measure that combines column values without aggregation will error out. 

 

Hope that helps. 

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.