i want 1st letter in Capital from each word . example i have names like ASHWINI LATA , so i want result like Ashwini Lata. how to do in power automate flow
If you want to do this with just one expression, the name must not exceed the number of words that this expression can handle (here up to 4 words, but this pattern is easily extendable):
concat(
toUpper(
substring(
outputs('Compose'), 0, 1)
),
substring(
if(
less(
nthIndexOf(outputs('Compose'), ' ', 1),
0
),
toLower(outputs('Compose')),
if(
less(
nthIndexOf(outputs('Compose'), ' ', 2),
0
),
replace(
toLower(outputs('Compose')),
substring(
toLower(outputs('Compose')),
nthIndexOf(toLower(outputs('Compose')), ' ', 1),
2
),
toUpper(
substring(
toLower(outputs('Compose')),
nthIndexOf(toLower(outputs('Compose')), ' ', 1),
2
)
)
),
if(
less(
nthIndexOf(outputs('Compose'), ' ', 3),
0
),
replace(
replace(
toLower(outputs('Compose')),
substring(
toLower(outputs('Compose')),
nthIndexOf(toLower(outputs('Compose')), ' ', 1),
2
),
toUpper(
substring(
toLower(outputs('Compose')),
nthIndexOf(toLower(outputs('Compose')), ' ', 1),
2
)
)
),
substring(
toLower(outputs('Compose')),
nthIndexOf(toLower(outputs('Compose')), ' ', 2),
2
),
toUpper(
substring(
toLower(outputs('Compose')),
nthIndexOf(toLower(outputs('Compose')), ' ', 2),
2
)
)
),
replace(
replace(
replace(
toLower(outputs('Compose')),
substring(
toLower(outputs('Compose')),
nthIndexOf(toLower(outputs('Compose')), ' ', 1),
2
),
toUpper(
substring(
toLower(outputs('Compose')),
nthIndexOf(toLower(outputs('Compose')), ' ', 1),
2
)
)
),
substring(
toLower(outputs('Compose')),
nthIndexOf(toLower(outputs('Compose')), ' ', 2),
2
),
toUpper(
substring(
toLower(outputs('Compose')),
nthIndexOf(toLower(outputs('Compose')), ' ', 2),
2
)
)
),
substring(
toLower(outputs('Compose')),
nthIndexOf(toLower(outputs('Compose')), ' ', 3),
2
),
toUpper(
substring(
toLower(outputs('Compose')),
nthIndexOf(toLower(outputs('Compose')), ' ', 3),
2
)
)
)
)
)
),
1
)
)
If your input value is always just the name in uppercase:
Select
From
split(outputs('Compose'), ' ')
Map
concat(
slice(item(), 0, 1),
toLower(substring(item(), 1))
)
Compose 2
join(body('Select'), ' ')
Hi @Ashwiniy !
You can use this flow for reference.
Flow:
Flow details:
In here, I have kept the name in a variable or it could be coming from Compose action in your case and then I split it by using space so you can get an array. Like this:
[
"NATHAN",
"ALVARES"
]
Expression used:
split(variables('inputString'), ' ')
Next...
I initialized an array to then store each word. In the apply to each, I used an expression to only take the first letter of each word, capitalize it while making the other letters in lower case and append to that array.
Expression used:
concat(toUpper(substring(items('Apply_to_each'), 0, 1)), toLower(substring(items('Apply_to_each'), 1, sub(length(items('Apply_to_each')), 1))))
Lastly...
I used a "Compose" action to finally join the array by using space as its delimiter.
Expression used:
join(variables('wordsArray'),' ')
WarrenBelz
146,645
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,997
Most Valuable Professional