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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Filtering Array based ...
Power Automate
Unanswered

Filtering Array based on condition from nested array

(1) ShareShare
ReportReport
Posted on by 2
Hi 
 
Need help with filtering this data based on data in nested array 
 
Input 
 
[
  {
    "id": "1727825406546",
    "attachments": [],
    "mentions": [],
    "reactions": []
  },
  {
    "id": "1727741971470",
    "attachments": [
      {
        "id": "announcement-card-720f1fc6f1ce4454ab3fe65fad0b729d",
        "contentType": "application/vnd.microsoft.teams.messaging-announcementBanner",
        "teamsAppId": "announcement-card"
      },
      {
        "id": "cc4d3943-69d2-426b-994f-d3d62dbbc34b",
        "contentType": "reference",
        "name": "CAMDEN_2024_Teams_background_v02 (1).jpg"
      }
    ],
    "mentions": [],
    "reactions": []
  },
  {
    "id": "1727247153493",
	"attachments": [
      {
        "id": "d4b3f882897646a49294dbcd606fd718",
        "contentType": "application/vnd.microsoft.card.adaptive",
		"teamsAppId": "announcement-card"
	  }
  }
 ]
 
 
I would like to filter this array where attachment array is not empty and contentType element contain "Adaptive"
 
 
Result should be 
 
{
    "id": "1727247153493",
	"attachments": [
      {
        "id": "d4b3f882897646a49294dbcd606fd718",
        "contentType": "application/vnd.microsoft.card.adaptive",
		"teamsAppId": "announcement-card"
	  }
  }
 
 
 
 
 
Categories:
I have the same question (0)
  • AlexEncodian Profile Picture
    4,409 Moderator on at
    Try this:

    Filter 1: length(item()?['attachments']) is greater than 0 to check if attachments array is not empty
     
    Filter 2: contains(item()?['attachments']?['contentType'], 'adaptive')

     

  • Chriddle Profile Picture
    8,443 Super User 2025 Season 2 on at
    Pls check JSON before posting 
     
     
    From:
    xpath(
    	xml(json(concat('{"Root":{"Item":', outputs('Compose'),'}}'))),
    	'//Item[contains(attachments/contentType, "adaptive")]'
    )
    Map:
    json(item())['Item']
  • Amardeep Raj Profile Picture
    18 on at
    Hi there,
     
    Here is the answer to your question
     
    2. Filter Parent Array Where any attachment contains adaptive
     
    @{xpath(xml(json(concat('{"body":{"value":', outputs('Compose_Sample_Data') , '}}'))), '/body/value[attachments/contentType[contains(text(), "application/vnd.microsoft.card.adaptive")]]')}



     
     
    3. Initialize variable
     



     
     
     
     
     



     


     
    If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.
     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard