cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JesusPrim
Regular Visitor

How to filter an array with an expression?

Hi I'd like to filter this array

 

[
  {
    "Id": "JTJmZG9jdW1lbnRsaWJyYXJ5JTJmRXN0YWRvK2RlK0N1ZW50YSUyZjIwMjEwNyUyZjIwMjEwNy0xMjM0NTYucGRm",
    "Name": "202107-123456.pdf",
    "DisplayName": "202107-123456.pdf",
    "Size": 11598,
  },
  {
    "Id": "JTJmZG9jdW1lbnRsaWJyYXJ5JTJmRXN0YWRvK2RlK0N1ZW50YSUyZjIwMjEwNyUyZjIwMjEwNy0xMjM0NTcucGRm",
    "Name": "202107-123457.pdf",
    "DisplayName": "202107-123457.pdf",
    "Size": 11598
  },
  {
    "Id": "JTJmZG9jdW1lbnRsaWJyYXJ5JTJmRXN0YWRvK2RlK0N1ZW50YSUyZjIwMjEwNyUyZjIwMjEwNy0xMjM0NTgucGRm",
    "Name": "202107-123458.pdf",
    "DisplayName": "202107-123458.pdf",
    "Size": 11598
  }
]

 

basically I need to filter the object.Name = "202107-123456.pdf"  

but I need to filter by making splits and just validate this 123456.

to be able to get this object like this:

 

 {
    "Id": "JTJmZG9jdW1lbnRsaWJyYXJ5JTJmRXN0YWRvK2RlK0N1ZW50YSUyZjIwMjEwNyUyZjIwMjEwNy0xMjM0NTYucGRm",
    "Name": "202107-123456.pdf",
    "DisplayName": "202107-123456.pdf",
    "Size": 11598,
  }

 

I did something like this but returns Empty array.

JesusPrim_0-1627710665990.png

 

@equals(split(split(item()?['Name'], '.')[0], '-')[1], '123456')

 

thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Gopala_Krishna
Solution Sage
Solution Sage

@JesusPrim 

Instead of splitting it you can make use of the contains action, it helps to check whether a collection has a specific item. Return true when the item is found, or return false when not found. This function is case-sensitive.

 

I have tried doing a test from my side and it is working as expected and I was able to get the resulting value.

 

Gopala_Krishna_0-1627717528131.png

------------------------------------------------------------------------------------------------------------------------------

If the information shared helps, please consider giving a thumbs up 👍 and mark solution as resolved

View solution in original post

1 REPLY 1
Gopala_Krishna
Solution Sage
Solution Sage

@JesusPrim 

Instead of splitting it you can make use of the contains action, it helps to check whether a collection has a specific item. Return true when the item is found, or return false when not found. This function is case-sensitive.

 

I have tried doing a test from my side and it is working as expected and I was able to get the resulting value.

 

Gopala_Krishna_0-1627717528131.png

------------------------------------------------------------------------------------------------------------------------------

If the information shared helps, please consider giving a thumbs up 👍 and mark solution as resolved

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,892)