cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ericshufro
Helper I
Helper I

How do i filter an array of json objects based on a object field?

Hello.  I am trying to filter out json objects from an array.  The goal is to:

1. Allow through the filter anyone whose job title is null.

2. Block anyone whose job title contains 'Director' or 'Manager'

3. Allow all remaining

 

I tried the following, but its not quite right and all objects seems to pass though.

 

ericshufro_0-1648669405709.png

 

@OR(equals(item()?['JobTitle'], null), or(not(contains(item()?['JobTitle'], 'Manager')), not(contains(item()?['JobTitle'], 'Director'))))

 

The data is formatted as:

[

  {
    "Mail""a@y.com",
    "DisplayName""John Doe 1",
    "JobTitle""Director, Engineering",
    "AccountEnabled"true
  },
  {
    "Mail""b@y.com",
    "DisplayName""John Doe 2",
    "JobTitle""Associate Director, Engineering",
    "AccountEnabled"true
  },
  {
    "Mail""c@y.com",
    "DisplayName""John Doe 3",
    "JobTitle""Sr. Staff Engineer, Software",
    "AccountEnabled"true
  },

 

Thanks in advance.

 

-e

2 ACCEPTED SOLUTIONS

Accepted Solutions
Mira_Ghaly
Dual Super User II
Dual Super User II

@ericshufro 

Please use the below expression:

@and(not(contains(item()?['JobTitle'], 'Director')),not(contains(item()?['JobTitle'], 'Manager')))
If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here

View solution in original post

Very close. 

 

See below.

 

@OR(equals(item()?['JobTitle'], null), and(not(contains(item()?['JobTitle'], 'Director')),not(contains(item()?['JobTitle'], 'Manager'))))

View solution in original post

3 REPLIES 3
Mira_Ghaly
Dual Super User II
Dual Super User II

@ericshufro 

Please use the below expression:

@and(not(contains(item()?['JobTitle'], 'Director')),not(contains(item()?['JobTitle'], 'Manager')))
If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here

Will this cover the null check?  Seems to still be an issue.

Very close. 

 

See below.

 

@OR(equals(item()?['JobTitle'], null), and(not(contains(item()?['JobTitle'], 'Director')),not(contains(item()?['JobTitle'], 'Manager'))))

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,908)