TrimEnds

How to Use the Power Fx TrimEnds  Function in Power Apps

What is the TrimEnds Function?

The TrimEnds function is a string manipulation function that allows you to remove characters from the end of a string. This function is useful when you need to remove spaces or other characters from the end of a string that may be causing issues in your app.

The syntax for the TrimEnds function is as follows:


TrimEnds( Text )


Where `Text` is the string that you want to remove characters from.

How to Use the TrimEnds Function

Using the TrimEnds function in Power Apps is relatively simple. Here is an example of how to use this function:

1. Create a new canvas app in Power Apps.

2. Add a Text Input control to the app.

3. Set the Default property of the Text Input control to "Hello World ".

4. Add a Label control to the app.

5. Set the Text property of the Label control to the following formula:


TrimEnds(TextInput1.Text)


6. Run the app and observe that the label displays "Hello World" without any spaces at the end.

In this example, we used the TrimEnds function to remove spaces from the end of the string "Hello World ". The resulting string "Hello World" was then displayed in a Label control.

Additional Examples

Here are some additional examples of how you can use the TrimEnds function in your Power Apps:

Remove Trailing Commas

If you have a string that ends with a comma, you can use the TrimEnds function to remove the comma. Here is an example:


TrimEnds(“Apples, Oranges, Bananas,”)


The resulting string will be "Apples, Oranges, Bananas".

Remove Trailing Dots

If you have a string that ends with a dot, you can use the TrimEnds function to remove the dot. Here is an example:


TrimEnds(“www.example.com.”)


The resulting string will be "www.example.com".

Remove Trailing Whitespace

If you have a string that ends with whitespace, you can use the TrimEnds function to remove the whitespace. Here is an example:


TrimEnds(” Example “)


The resulting string will be " Example".

The TrimEnds function is a simple but powerful function in Power Apps that allows you to remove characters from the end of a string. This function can be used to fix issues with strings that may contain unwanted characters. By following the examples outlined in this article, you should now be able to use the TrimEnds function in your own Power Apps.

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