How to Use the Power BI DAX function TRIM

What is the TRIM function?

The TRIM function in DAX is used to remove extra spaces from a text string. It removes all leading and trailing spaces, as well as any extra spaces between words. The function takes a single argument, the text string you want to clean up, and returns the trimmed text string.

How to use the TRIM function

Using the TRIM function is easy. Simply follow these steps:

1. Open your Power BI report and navigate to the Data view.

2. Select the column that contains the text strings you want to clean up.

3. Click on the Modeling tab in the ribbon.

4. Click on New Column to create a new calculated column.

5. Enter the following formula in the formula bar: `TRIM(Table1[Column1])`

Note that Table1 and Column1 should be replaced with the name of your table and column.

6. Click on the checkmark to apply the formula and create the new column.

Your new column will now contain the trimmed text strings. You can use this column in your visualizations and analysis tasks.

Tips for using the TRIM function

Here are some tips to keep in mind when using the TRIM function:

– The TRIM function is case-sensitive. This means that it will only remove spaces, not other types of whitespace such as tabs or line breaks.

– If you want to remove all additional whitespace, you can combine the TRIM function with the SUBSTITUTE function. For example, the formula `SUBSTITUTE(TRIM(Table1[Column1]),” “,””)` will remove all spaces from the text string.

– The TRIM function can also be used in combination with other DAX functions, such as CONCATENATE or SUBSTITUTE, to create more complex formulas.

The TRIM function in Power BI is a powerful tool for cleaning up text strings and ensuring consistency in your data. By removing extra spaces before and after text strings, you can avoid issues with filtering, sorting, and other data analysis tasks. With the tips and tricks outlined in this article, you can start using the TRIM function today to improve the quality of your data.

Power BI DAX Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

Contact Us


    Your Name (required)


    Email (required)


    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)