Filter Empty String From Array in Power Automate Flow
- D365 Freelancer
- Jul 5
- 1 min read
The Problem
I encountered this problem while writing a logic app, but it remains equally applicable to logic apps. I had an HTTP child logic app that was receiving a string array from a parent logic app. I had no control over the parent logic app. The parent logic app would, at times, include an empty string in the array, which would cause extra actions to be called, thereby incurring additional costs. Additionally, in some edge cases, the empty string value could also cause errors.
The Solution
Clean the string array by removing empty strings from it before using it.

The Power Automate Flow
The example flow below creates an array of John Wick movie titles + an empty string in a Compose action. Then, a Filter Array action removes the empty string and outputs just the movie titles.

The flow trigger is a scheduled trigger. This was used to make it quick and easy to build the flow.
The "Compose - Array" action builds the dirty array, which contains an empty string and John Wick movie title strings.
The "Filter array - Remove Empty String" action does precisely that: it cleans the dirty array by removing empty strings. The where clause @equals(empty(item()), false) looks for array items that are NOT empty.
For reference
As it might be helpful to Power Automate Developers, below is the Peek Code JSON from the "Filter array - Remove Empty String" action
{
"inputs": {
"from": "@outputs('Compose_-_Array')",
"where": "@equals(empty(item()), false)"
}
}
Comments