Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
10 years ago
Solved

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?

 

  • Anonymous's avatar
    Anonymous
    10 years ago

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

12 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    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

     

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

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

      • Kmow's avatar
        Kmow
        Icon for Advocate I rankAdvocate I

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

    • fraktol's avatar
      fraktol
      Regular Visitor

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

  • Anonymous's avatar
    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's avatar
    v-haibl-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Anonymous

     

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

     

    Best Regards,

    Herbert

  • 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. 
  • GlennHG's avatar
    GlennHG
    Regular Visitor

    It is quiet unfortunate that, still a lot of responders could not differentiate between DAX and Power Query M. 😞