Forum Discussion

lpriceFTW's avatar
lpriceFTW
Icon for Helper II rankHelper II
2 years ago
Solved

DAX: Apply trim (or any string function) to entire column

I want to trim the contents of an entire column in DAX.   It is a measure table, so I did not create this in PowerQuery M.   Does the ability exist within DAX to do this?   Example:   Origina...
  • Anand24's avatar
    2 years ago

    Hi lpriceFTW ,
    I guess Power BI automatically trims the values to eliminate additional spaces anywhere. 
    Just in case it doesn't, you can use TRIM function like below DAX:

    1. For a trimmed new calculated column:

    Trimmed Header = TRIM('Table'[Header])
     

    2. For a trimmed new calculated measure:

    Trimmed Header = TRIM(MAX('Table'[Header]))

     

     

    Give a Thumbs Up if this post helped you in any way and Mark This Post as Solution if it solved your query !!!

    Proud To Be a Super User !!!
    LinkedIn

  • Uzi2019's avatar
    2 years ago

    Hi lpriceFTW 
    PBI auto Trim the white space in the column.I have taken your data.

    when I take the data in visual / table then it auto display the values without white space.

     

    Or if still is it there you can take TRIM() in measure like below.

    Trim Header = TRIM(MIN('Trim Table'[Header]))

    It gives the same result. 

     

    I hope I answered your question!