Forum Discussion

Rohini's avatar
Rohini
Helper I
6 years ago
Solved

Add space tab Dax

Hi  PBI Comm,

 

What is the DAX or M to add spaces or a tab (space) in front of a text value.

  • Hi Rohini 

    I m not clearly understand you needs but you can create a columns like

    New column = " " & Table[OldColumn]

    or 

    New column = CONCATENATE( " ", Table[OldColumn])

    or

    New column = CONCATENATE(UNICHAR(32), Table[OldColumn])​

     

  • Hi Rohini ,

     

    For DAX, you could use the formulas that az38 suggests. For M, you could try below:

    = Table.AddColumn(#"Changed Type", "Custom1", each Text.Insert(Text.From([Column1]),2," "))

     

     

    = Table.AddColumn(#"Changed Type", "Custom", each  "   " & [Column1])

     

    And there is a thread about add space in the middle. You could reference to have a try,

    https://community.powerbi.com/t5/Power-Query/Find-a-string-add-a-space-in-the-middle/m-p/714533

     

    If these can't help you, please share some sample data and expected output. We will understand clearly about your request.

     

4 Replies

  • az38's avatar
    az38
    Community Champion

    Hi Rohini 

    I m not clearly understand you needs but you can create a columns like

    New column = " " & Table[OldColumn]

    or 

    New column = CONCATENATE( " ", Table[OldColumn])

    or

    New column = CONCATENATE(UNICHAR(32), Table[OldColumn])​

     

    • ak77's avatar
      ak77
      Post Patron

      Hi  az38 ,

       

      i tried below 3 DAX options to achive space at the beginning of the Column value.. but its not working .. Can you please help.. i need to achive Space at the beginning of the column value like below

       

       

      ew column = " " & Table[OldColumn]

      or 

      New column = CONCATENATE( " ", Table[OldColumn])

      or

      New column = CONCATENATE(UNICHAR(32), Table[OldColumn

       

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

        Write any of those as calculated column formulas (not as measures).

  • v-xuding-msft's avatar
    v-xuding-msft
    Community Support

    Hi Rohini ,

     

    For DAX, you could use the formulas that az38 suggests. For M, you could try below:

    = Table.AddColumn(#"Changed Type", "Custom1", each Text.Insert(Text.From([Column1]),2," "))

     

     

    = Table.AddColumn(#"Changed Type", "Custom", each  "   " & [Column1])

     

    And there is a thread about add space in the middle. You could reference to have a try,

    https://community.powerbi.com/t5/Power-Query/Find-a-string-add-a-space-in-the-middle/m-p/714533

     

    If these can't help you, please share some sample data and expected output. We will understand clearly about your request.