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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
lpriceFTW
Helper II
Helper II

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:

 

Original Table:

Header
my text
     my    text
  this text
text    my

 

 

After Trim Table:

Header
my text
my text
this text
text my

 

 

 

 

 

 

 

 

2 ACCEPTED SOLUTIONS
Anand24
Super User
Super User

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]))

 

PBI_SuperUser_Rank@1x.png  

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

View solution in original post

Uzi2019
Super User
Super User

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

Uzi2019_0-1699602378677.png

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

Uzi2019_1-1699602430889.png

 

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

Trim Header = TRIM(MIN('Trim Table'[Header]))
Uzi2019_2-1699602594669.png

It gives the same result. 

 

I hope I answered your question!

 

 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

View solution in original post

5 REPLIES 5
Uzi2019
Super User
Super User

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

Uzi2019_0-1699602378677.png

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

Uzi2019_1-1699602430889.png

 

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

Trim Header = TRIM(MIN('Trim Table'[Header]))
Uzi2019_2-1699602594669.png

It gives the same result. 

 

I hope I answered your question!

 

 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Hey thanks for the reply.

 

I ended up just creating a calculated column on the untrimmed measure table like you mentioned. I used the calculated trim column for my table relationships.

 

lpriceFTW_0-1699623140167.png

Anonymous
Not applicable

Hi @lpriceFTW ,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information and description to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Anand24
Super User
Super User

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]))

 

PBI_SuperUser_Rank@1x.png  

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

Hey thanks for the reply.

 

I ended up just creating a calculated column on the untrimmed measure table like you mentioned. I used the calculated trim column for my table relationships.

 

lpriceFTW_0-1699623140167.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors