web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to use filter arra...
Power Automate
Unanswered

How to use filter array with multi column compose output

(0) ShareShare
ReportReport
Posted on by 51

Hello!

 

I have a variable array with 2 columns:

 

Name: varContacts

 

Value: 

 

{
 "ContactName": DynamicDataHere,
 "Specialty" DynamicDataHere
}

 

 

My source list will often have duplicates, so I consolidate with a Compose:

Inputs:

 

union(variables('varContacts'),variables('varContacts'))

 

 

Now I'm trying to apply a filter array to another SharePoint list AdditionalContacts with the common field being "Specialty" vs AdditionalSpecialty, but i can't figure out how to reference the "Specialty" Column in the Compose Array to compare it to the AdditionalSpecialty Column in the AdditionalContacts list.

 

Example data in the Compose outputs:

 

ContactNameSpecialty
User APainting
User BSculpting
User CWriting

 

 

Example data in Sharepoint List AdditionalContacts

AdditionalContactNameAdditionalSpecialty
User 1Writing
User 2Reading
User 3Sculpting

 

Desired Filter array output in an Apply to each loop: 

Loop#AdditionalContactNameAdditionalSpecialty
1User 3Sculpting
2User 1Writing

 

 

Current Filter Array setup (not working):

 

From:

value of (Get items AdditionalContacts)

   item()?['AdditionalContactSpecialty'] is equal to outputs('Compose')['Specialty']

which throws an error: 

The execution of template action 'Filter_array' failed: The evaluation of 'query' action 'where' expression '@equals(item()?['AdditionalSpecialty'], outputs('Compose')['Specialty'])' failed: 'The template language expression 'equals(item()?['AdditionalSpecialty'], outputs('ComposeUnion')['Specialty'])' cannot be evaluated because property 'Specialty' cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.'.

 

Any guidance would be greatly appreciated, thanks!

Categories:
I have the same question (0)
  • WillPage Profile Picture
    2,311 Super User 2026 Season 1 on at

    Do a Select action from Data Operations. In the Select, switch to raw JSON input mode and put the expression item()?['Specialty']. This will result in a single column array which you can now use in the left hand side operand of the contains filter.

  • ImaKickUrAsh Profile Picture
    51 on at

    Hi @WillPage thanks for the quick reply.  I was trying to keep the array together because I'm going to use it for email notifications later in the flow. Is there no way to reference a specific column from a compose output in a filter array?

  • WillPage Profile Picture
    2,311 Super User 2026 Season 1 on at

    You still have access to the original array, just use the dynamic content from the original variable when you need it and use the output of the Select purely for filtering the other thing

  • grantjenkins Profile Picture
    11,063 Moderator on at

    A couple of questions:

    1. What data type is the SharePoint List using for the users? Single line of text, Person, etc.
    2. Are the Additional Specialty values using Single line of text, or Choice field?
    3. Can there be more than one additional contact for each specialty. For example, could there be 2 or more additional contacts for Writing (as shown in the table below)?
    AdditionalContactName AdditionalSpecialty
    User 1 Writing
    User 2 Reading
    User 3 Writing
    User 4 Sculpting
  • grantjenkins Profile Picture
    11,063 Moderator on at

    Below is how I would likely build the flow to get what you want. Note that it doesn't use an Apply to each which makes it much more efficient, especially if you have a lot of records to process.

     

    I've based it on the following assumptions:

    • Title field used for the User in the SharePoint List (Single line of text)
    • Additional Specialty field is Single line of text
    • There is only ever a single Additional Contact for each Specialty

     

    Below is the SharePoint List used for this example.

    grantjenkins_0-1698315391106.png

     

    Below is the full flow. I'll go into each of the actions.

    grantjenkins_1-1698315415958.png

     

    Contacts is the array variable called varContacts that contains the initial contacts.

    grantjenkins_2-1698315498363.png

     

    [
     {
     "ContactName": "User A",
     "Specialty": "Painting"
     },
     {
     "ContactName": "User B",
     "Specialty": "Sculpting"
     },
     {
     "ContactName": "User C",
     "Specialty": "Writing"
     }
    ]

     

     

    Get items retrieves the additional contacts. Note that the Get items action will only return the first 100 items by default. If you have more than this you would need to change the Top Count to accommodate. I've set mine to 5000.

    grantjenkins_3-1698315585747.png

     

    XML is a Compose that converts the items returned from Get items to XML so we can use XPath expressions to retrieve the matching data without having to use an Apply to each. The expression used is:

     

    xml(json(concat('{"root": { value:', outputs('Get_items')?['body/value'], '}}')))

     

    grantjenkins_4-1698315671540.png

     

    Select uses the varContacts data and the following expressions to build up the object array. Note that this will list all the Contacts regardless of whether they have an additional contact. If they don't have an additional contact, then AdditionalContactName will have an empty value.

     

    //ContactName
    item()?['ContactName']
    
    //Specialty
    item()?['Specialty']
    
    //AdditionalContactName
    xpath(xml(outputs('XML')), concat('string(//root/value[AdditionalSpecialty=''', item()['Specialty'], ''']/Title/text())'))

     

    grantjenkins_5-1698315770873.png

     

    This would give you the following output.

     

    [
     {
     "ContactName": "User A",
     "Specialty": "Painting",
     "AdditionalContactName": ""
     },
     {
     "ContactName": "User B",
     "Specialty": "Sculpting",
     "AdditionalContactName": "User 3"
     },
     {
     "ContactName": "User C",
     "Specialty": "Writing",
     "AdditionalContactName": "User 1"
     }
    ]

     

     

    If you then wanted to filter out the contacts that don't have an additional contact, you can use a Filter array.

     

    Filter array uses the output from the Select and the following expression.

     

    item()?['AdditionalContactName']

     

    grantjenkins_6-1698316006328.png

     

    This will give you the final output.

     

    [
     {
     "ContactName": "User B",
     "Specialty": "Sculpting",
     "AdditionalContactName": "User 3"
     },
     {
     "ContactName": "User C",
     "Specialty": "Writing",
     "AdditionalContactName": "User 1"
     }
    ]

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 286

#2
David_MA Profile Picture

David_MA 256 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 225 Most Valuable Professional

Last 30 days Overall leaderboard