top of page

Power Apps Text Functions Deep Dive

In today's post, we're diving into the world of text (or string) functions in Power Apps. If you're working with any kind of data, chances are you'll need to manipulate strings at some point. Whether it's reformatting text, cleaning up user inputs, or extracting specific data, these functions are a key ninja skill you should develop. 🥷


Below we will talk through 17 different Power FX functions that allow you to manipulate your Power Apps data in all ways regardless of if it comes from your users via inputs or from your data sources like Dataverse, SharePoint, SQL, or the other twelve hundred that are available.


And because I am super nice there is a code example of each so you can see the practical example and easily cut and paste. 😁 Finally, if you want to see the examples and hear the more detailed explanation of using these Power FX functions, then check out my video on Power Apps Text Functions. It might not win an Emmy, but maybe a Golden Globe?


Split, Last, and First Functions

One of the most common text challenges you'll encounter is splitting and reformatting strings. A classic example is converting names from "Last, First" format to "First Last".


Using the Split function, you can break a string into pieces based on a delimiter (like a comma). From there, the Last and First functions come into play, allowing you to rearrange and clean up the data as needed.


Example: Suppose you have a name formatted as "Young, Shane." By splitting on the comma and using First and Last, you can easily reformat it to "Shane Young."

Power Apps Split, Last, and First functions example
Trim(Last(Split(TextInput1.Text, ",")).Value) & " " & First(Split(TextInput1.Text, ",")).Value

Index Function

Need to grab a specific part of a string, like a middle name? The Index function is your go-to tool. This function retrieves a specific row from a table created by a split function.


Example: Splitting "Shane Dog Young" on the spaces between the words would create a table with three rows. The Index function allows you to pull out the second row, which would be "Dog" in this case.


Power Apps Index function example
Index(Split(TextInput2.Text, " "),2).Value

Right, Left, Mid, and Find Functions

When you're working with structured text, like invoice numbers or IDs, you'll often need to extract a fixed number of characters. The Right and Left functions allow you to grab a specific number of characters from the end or beginning of a string.


For more complex cases, the Mid function is a lifesaver. It lets you extract characters from anywhere in a string, based on a starting point and length. Combine it with the Find function to locate specific characters or patterns in your text.


Example: Use Right to grab just the last four digits of a string that represent the invoice number. Or use Left to get the first view characters. This works best when you know the structure of the data, and know it will not change.

Power Apps Right function and Left function example
Right(TextInput3.Text, 4)
Left(TextInput3.Text, 3)

Example: Combining Mid and Find is another way to locate part of a string, like earlier when we used Split. The difference here is you might be finding a specific character(s) within the string to start from.

An example of the Power Apps Mid and Find functions.
Mid(TextInput5.Text,Find("-", TextInput5.Text) + 1, 3)

Len Function

Sometimes, you just need to know how long a string is. That's where the Len function comes in. This function counts the number of characters in a string and is particularly useful when validating inputs or calculating positions in more complex formulas.


Example:Use Len to ensure that phone numbers or codes meet length requirements before processing them further.

The Power Apps Len function
Len(TextInput6.Text)

Upper, Lower, and Proper Functions

Standardizing text case is crucial for data consistency. Whether you need everything in uppercase, lowercase, or proper case, these functions have you covered.


The Upper function converts all characters to uppercase, Lower converts them to lowercase, and Proper capitalizes the first letter of each word. This is especially useful for normalizing names or email addresses to avoid case-sensitive issues.


Example: Use Lower or Upper to standardize email addresses before comparing them, or Proper to clean up user-entered names.


Examples of Power Apps text functions using Upper Function, Lower Function, and Proper Function
Upper(TextInput7.Text)
Lower(TextInput7.Text)
Proper(TextInput7.Text)
Are you enjoying this learning style? Be sure to check out some of my Power Apps and Copilot Training classes. Both Live and On-demand courses available.

Trim and TrimEnds Functions

Whitespace can be a sneaky issue in user inputs, causing mismatches and errors in your app. The Trim function removes all extra spaces from a string, including those between words. TrimEnds, on the other hand, only removes spaces from the beginning and end of the string.


These functions are perfect for cleaning up user inputs and ensuring data consistency, particularly when dealing with form fields or imported data. Those people writing Power BI reports from your data will thank you.


Example: Use Trim to clean up a user-entered address or TrimEnds to remove accidental trailing spaces in email inputs.

Trim function and TrimEnds Power FX functions
Trim(TextInput9.Text)
TrimEnds(TextInput9.Text)

Replace and Substitute Functions

Sometimes, you need to swap out certain text in a string. The Replace and Substitute functions allow you to do just that, but with a key difference:


  • Replace targets a specific position in the string and replaces it with new text.

  • Substitute finds all occurrences of a specific text and replaces them.


Example: Replace a specific word in a sentence or substitute all instances of a special character in a text field.

The Replace Function and the Substitue Function for Power Apps String Manipulation
Replace(TextInput8.Text,9,4,"really love")
Substitute(TextInput8.Text,"like","🥰")

Concat Function

The Concat function is the opposite of Split we learned earlier. It takes a table of data and combines it into a single string. This is extremely useful when you need to generate lists from selected items, such as creating a list of email addresses from a Combo Box SelectedItems output.


Example: Use Concat to combine multiple selected values into a semicolon-separated list for an email field.

The Power Apps concat function is very helpful when converting Tables to Text.
Concat(ComboBox1.SelectedItems,Value,"; ")

String Interpolation

Finally, let's talk about string interpolation – the newer, fancier way to concatenate strings in Power Apps. With this method, you use dollar signs ($) and curly braces ({}) to embed dynamic content within your strings.


While the old-school & (Ampersand) method still works just fine, string interpolation offers a cleaner and more intuitive way to build strings. Though, thanks to muscle memory, I still use the old way. 🤷


Example: Use interpolation to dynamically insert user names, dates, or other variables into your strings with minimal fuss. As you can see, both ways produce the same output, really just a matter of what works best for you.

Different ways to Concatenate text in Power Apps
$"The user {User().FullName} typed {TextInput10.Text} in the box."
"The user " & User().FullName & " typed " & TextInput10.Text & " in the box."

Wrapping up Power Apps Text Functions

Text manipulation is a fundamental skill in Power Apps, enabling you to clean, structure, and transform your data with ease. Whether you're working on a simple form or a complex data process, mastering these text functions will make your apps more robust and reliable.


I hope this guide helps you tackle your text challenges with confidence! As always, feel free to reach out if you need assistance, whether it’s a quick fix or a more involved project.


Need Power Apps String Function Help?

If you need help with this or any other Power Platform topic we are here to help. We can do everything from a quick 30-minute fix to a 30-year project. We also have lots of training classes. (I really want to say 30 courses to stick with the 30 theme but I'm not sure that is true. 🤣 I guess I should count them.)

323 views0 comments

Commentaires


bottom of page