“I’d like to standardise the data I receive and make the first character always upper case, what’s the easiest solution in Power Automate?”
When you collect data from various sources, the format can be quite different. Some system can have the information in upper case, some in lower case, and some in a variation of both. Yet for the users it should always look the same. How do you standardise the text format? To make only the first character upper case and all the rest in lower case?
Split the text into 1st character and the rest
Since you’re trying to apply different format on the first character, you must isolate it from the whole text. As such you must split it into two pieces – the first character and the rest.
The easiest way to take the first character is to use the take(…) expression. This expression can be used on strings or arrays and will return the desired number of items / characters.
take(<string>, <numberOfCharactersToTake>)
Note: <…> are placeholders, replace them including the < and >.
Here you want only in the first character.
take(<string>, 1)
As an example, if I want to standardise the statuses in an approval process, it could look as below:
take('new request', 1) = 'n'
That’s the first character, now for the rest – the remaining text without the first character. To do that use another expression that’s often used together with take(…), the skip(…) expression. While take(…) will take a number of characters and ignore the rest, skip(…) will skip a number of characters and take the rest.
skip(<string>, <numberOfCharactersToSkip>)
In this case you want to skip only the first character.
skip(<string>, 1)
skip('new request', 1) = 'ew request'
Make the text upper or lower case
Now, when you have the two pieces of text for different formatting, you can apply the upper / lower case. The first character should be upper case…
toUpper(take(<string>, 1))
…the rest should be lower case…
toLower(skip(<string>, 1))
…and it should be concatenated back into a single string.
concat(toUpper(take(<string>, 1)), toLower(skip(<string>, 1)))
Summary
The most complicated part on making the first character upper case in Power Automate is to isolate it. Luckily, Power Automate has two expressions that make this task very easy. Take(…) the first character, skip(…) it to take the rest, and apply the toUpper(…) or toLower(…) expressions to format the text.
Hi Tom, in a situation where you want the first letter to be capital for the first and last name. How would you do this ?
I found out but this is not an easy one for me. I need four compose action.
– The first one named “initial” with contains my first and last name.
– The second one named “first” with the following expression : concat(toupper(take(substring(outputs(‘initial’),0,indexof(outputs(‘initial’),’ ‘)),1)),
tolower(skip(substring(outputs(‘initial’),0,indexof(outputs(‘initial’),’ ‘)),1)))
– The third one named “last” with the following expression : substring(outputs(‘initial’),add(indexof(outputs(‘initial’),’ ‘),1))
– The fourth one named “complete” with the following expression :
concat(outputs(‘first’),’ ‘,concat(toupper(take(substring(outputs(‘last’),0,indexof(outputs(‘last’),’ ‘)),1)),tolower(skip(substring(outputs(‘last’),0,indexof(outputs(‘last’),’ ‘)),1))))
Can this be done easier ?