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 / 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,686 Super User 2026 Season 1 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
    56 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

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!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 801

#2
Valantis Profile Picture

Valantis 602

#3
Haque Profile Picture

Haque 581

Last 30 days Overall leaderboard