Sometimes strings in Power Automate need to be reformatted so that the first letter of each word is capitalized. This is know as “Proper Case”. There is no function built in to perform this common task. PowerApps does have this function so I expect it will arrive on Power Automate eventually.
In the mean time, here is an example flow and the required code to convert a string to Proper Case. The goal is to transform the sample string “this is a TEST” to “This Is A Test”
Example Proper Case Flow
Proper case is simple to achieve, take a look at this sample flow:
Explanation:
- The phrase to be transformed is added to a compose step.
- An apply to each is started and the input is a split expression which splits the phrase into an array.
- Each word is then passed into an expression which makes the first letter of the word uppercase and the remainder lower case.
- The final step of the flow uses a join expression to put the phrase back together again with spaces between each word.
The expression in the flow step “Capitalize each word” is:
if ( equals(length(item()),1), toupper(item()), concat(first(toupper(item())),toLower(substring(item(),1,sub(length(item()),1)))) )
Explanation of the expression:
- If the length of the word is only 1 letter, just output the uppercase representation of the word.
- If the word is longer than 1 character then uppercase the first letter of the word and lowercase the remainder.
I decided to write this up after someone asked how this could be done on the Power Automate community forums. He was following a blog post written by Elaiza Benitez that performs the same function.
My flow is mostly the same, but also works when one of the words has only one letter.
Hope this helps you out until the Power Automate team add a Proper Case function.