Skip to main content

Notifications

Power Platform Community / Forums / Building Flows / Filtering Array based ...
Building Flows
Unanswered

Filtering Array based on condition from nested array

Posted on by
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:
  • Chriddle Profile Picture
    Chriddle 6,750 on at
    Filtering Array based on condition from nested array
    Pls check JSON before posting 
     
     
    From:
    xpath(
    	xml(json(concat('{"Root":{"Item":', outputs('Compose'),'}}'))),
    	'//Item[contains(attachments/contentType, "adaptive")]'
    )
    Map:
    json(item())['Item']
  • AlexEncodian Profile Picture
    AlexEncodian 4,117 on at
    Filtering Array based on condition from nested array
    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')

     

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

September 2024 Newsletter…

September 2024 Community Newsletter…

Community Update Sept 16…

Power Platform Community Update…

Welcome to the new Power Platform Community!…

We are excited to announce our new Copilot Cookbook Gallery in the Community…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 141,122

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,414

Leaderboard

Featured topics