June 24, 2024

The Trim function is one handy function that most don’t understand the proper usage since it only serves one purpose. It is removing spaces. It only removes spaces from the beginning and end of a string, leaving single spaces within the string intact. Notice that I said single spaces, but we’ll get to that in a minute.


It follows a simple pattern.

  1. Text

That’s it. Provide a text, and the function removes the spaces. The first thing you need to be aware of is that the function removes all spaces in the beginning, but if there are extra spaces in the string, it will remove them until only one exists.

Let’s build a simple Power App that has a text input and a text label with the result of the trim. It will allow us to test a bunch of cases and see the result. The formula will always be the same:


Let’s start with the simplest case. No spaces in the beginning or end:

The result is what we expect. There aren’t any spaces to remove, so the string remains the same. Now let’s add some spaces.

The “Trim” function removes the initial spaces without interfering with the ones inside the string. Awesome.

Let’s add a few lines and see if it removes the lines’ carriage return.

Nothing is changed, so we’re good. What about an empty string, or one with only spaces?

The function returns an empty string since we only have spaces.

Let’s try one last test where we have extra spaces in the string.

If you’re a developer, you may be surprised with this one since some programming languages won’t touch the spaces inside the string, but Power Apps do, so be aware of that when doing your trimming.


  1. This function is never delegable, so be careful if you have an unusually large dataset. If you don’t know what this is, please check my article on delegation and my reference table of the data sources where Filter will be delegable. If not, the Power App will only display the first 500 values (default value up to 2000).


  1. If you want to remove only the spaces in the beginning and the end, you should use the “TrimEnds” function, which is consistent with most programming languages.
  2. Don’t nest the function. It’s not necessary since it always returns the same value.


Trim function in Power Apps

Back to the Power Apps Function Reference

Photo by Matt Bero on Unsplash

Manuel Gomes

I have 18 years of experience in automation, project management, and development. In addition to that, I have been writing for this website for over 3 years now, providing readers with valuable insights and information. I hope my expertise allows me to create compelling, informative content that resonates with the audience.

View all posts by Manuel Gomes →

Leave a Reply

Your email address will not be published. Required fields are marked *