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 / Most Efficient Way of ...
Power Automate
Answered

Most Efficient Way of Evaluating 365 Group Membership

(0) ShareShare
ReportReport
Posted on by 156

My question is as above but this isn't the first situation like this. Really I want to check that this approach is the 'recommended' way and im not missing a chance to make my flows more simple.

 

So I have a 365 group and within a flow I want to add someone to it. But I only want to add them if they're not already a member. Similarly, I may want to remove them - but only if they're a member. 

 

So the programmer in me wants to create the equivalent of 'if x is not a member of group y then add as member else do nothing'. But as far as I can tell the way to do it is to get group members, then work out if the person is in that array of members, then do whatever I want to do. I know it's not much different, but it still feels clunky.

 

Is there a better way of accomplishing this? Or is it just not the way Power Automate works?

Categories:
  • Verified answer
    Manish Solanki Profile Picture
    15,169 Moderator on at

    Hi @philjn77 

     

    You could use filter array action to check if user exists in the group without using loop. Here is an example:

     

    1. Add "List group members" action to get all users of a group:

    ManishSolanki_0-1701922976439.png

     

    2. Next, add filter array action, pass the value object to it. Write filter query to check if user with email address exits in the group:

    ManishSolanki_1-1701923058816.png

    click "Edit in advanced mode" link at the bottom of the action & write the below query in the textbox:

    @equals(item()?['mail'], 'm@m.onmicrosoft.com')

    pls replace with the email address to search for within the group.

     

    3. Add "Condition" action to check the length of array returned by filter array action. If length is greater than zero then user exits in the group else does not exists. We will use expression to determine the length of the array. Expression needs to be entered in the expression box as shown below:

    ManishSolanki_2-1701923278997.png

    length(body('Filter_array'))

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

    Thanks

  • Verified answer
    VictorIvanidze Profile Picture
    13,083 on at

    Most efficient way is executing a GRAPH request via "Send an HTTP request" action to check if the given user is a member of the given group.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 302 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 263

#3
Henil Profile Picture

Henil 115

Last 30 days Overall leaderboard