Trim

How to Use the Power Fx TrimĀ  Function in Power Apps

What is the Power Fx Trim Function?

The Trim function is a text function that helps you to remove unwanted spaces from a string value. The Power Fx Trim Function is a built-in function in Power Apps that does exactly the same thing. It removes all leading and trailing spaces from a string value and returns the remaining text.

How to Use the Power Fx Trim Function?

The syntax for using the Power Fx Trim Function is as follows:


Trim(text)


The Trim function takes a single argument, which is the text value that you want to remove spaces from. The text argument can be a text string or a column name that contains text values.

Let's take a simple example to understand how to use the Trim function. Suppose you have a text value in a variable called 'textValue'. The value of the variable is ' Power Apps '. To remove the leading and trailing spaces from this text value, you can use the Trim function as follows:


Trim(textValue)


The above expression will return the string 'Power Apps' without any leading or trailing spaces.

Additional Examples

Here are some additional examples of how to use the Power Fx Trim Function:

Example 1: Removing Spaces from a Text Input

Suppose you have a text input called 'txtInput', and you want to remove any leading or trailing spaces from the input value. To achieve this, you can use the Trim function in the default value of the input control as follows:


Trim(txtInput.Text)


This expression will remove any extra spaces from the input text value.

Example 2: Trimming Spaces from a Column Value

Suppose you have a SharePoint list that contains a column called 'Title'. The title column contains text values with leading or trailing spaces. You can use the Power Fx Trim Function to remove any extra spaces from the 'Title' column as follows:


Trim(ThisItem.Title)


This expression will remove any leading or trailing spaces from the 'Title' column value.

The Power Fx Trim Function is an essential function in Power Apps that helps you to remove extra spaces from text values. By using this function, you can ensure that your text values are consistent and free from any unwanted spaces. We hope this article has helped you to understand how to use the Power Fx Trim Function in Power Apps.

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