Search code examples
stringpower-automate

Power Automate Flow - 'Condition' to Check if 'Select' Action Output or Table or Excel File Contains a String


enter image description here enter image description here

I have the above flow:

  • The 'Follow-up' condition checks if the name of the attachment contains the word 'Follow'
  • Then the flow moves to create a file from the attachment
  • Then creates a table from the Excel sheet
  • Then lists the rows of the table
  • Then selects only few columns from the table
  • Then 'Filter Array check' action looks for certain strings using expression:

or(contains(item()?['Group'], 'Service-FRA'), contains(item()?['Group'], 'Service-NLD'))

  • Then the 'Condition NLD' checks if the body output of the 'Filter array check' is greater than zero before running further actions:

enter image description here

The problem with this method, it is breaking the entire flow, causing the first 'For each' action which comes before 'Get Attachment (V2)' to fail.

If i remove 'Condition NLD' from the flow and add some action directly, the flow works fine.

- Question:

Is there any better way to create a condition that checks if a certain string exists either in the Output of the 'Select' or the output of the table or the file itself?


Solution

  • You are trying to compare an array to a number that is why you are getting an error. Instead, you should be comparing the length of the array like this:

    condition

    where the expression is:

    length(body('Filter_array_check'))