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 Apps / Filter gallery by fiel...
Power Apps
Answered

Filter gallery by field in different source

(0) ShareShare
ReportReport
Posted on by 40

Hi I hope someone can give me some pointers with this one as it's a bit more complex than I've went before

I have a data source Refs which has amongst other fields the 'Team' name
I would like to filter the gallery based on logged in users 'Team' which is held in another source, Admin, containing User and Team
So filter Refs by Team = Team in Admin, where logged in user is found in Admin, else show all records in gallery
I have used var user in previous apps to filter by logged in user but that was simplier as eheir details were also in the data source so any assistance would be appreciated in expanding my knowledge with this
Sam

Categories:
  • Nogueira1306 Profile Picture
    7,390 Super User 2024 Season 1 on at

    I don´t think that I understood your quesiton.. But, you can always try to use Office365 groups. That seens the best idea to check if the user belongs to a certain gruop/team

     

    If you need additional help please tag me in your reply and please like my reply.
    If my reply provided you with a solution, pleased mark it as a solution ✔️!

    Best regards,
    Gonçalo Nogueira

    Check my LinkedIn!

    Check my User Group (pt-PT)!

  • Verified answer
    zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    App.OnStart

    Set(varUser,User())

    Set(varTeam,Lookup(Admin,varUser.Email=Email).TeamName)

    This two variable will store current user's info and current user's team name.

     

    In your gallery item code:

    If(IsBlank(varTeam),ref,Filter(ref,TeamName=varTeam);

     

    This code will first check if variable varTeam is empty or not. If it is empty meaning user is not in the admin list. And will see all the record. If it's not empty meaning user is in the admin list and will filter ref list according to current user's team

     

    Tweak it according to your need

  • Snazzybec Profile Picture
    40 on at

    thank you so much zmansuri,

    that sounds exactly like I wish it to work, I will try implementing today and see how it works 

     

    thanks again for your very clear guidance

    Sam

  • Snazzybec Profile Picture
    40 on at

    tried it and it works exactly as required
    this is what I used
    set Global variables in onstart of App

    Set(VarUser,User());

    Set(VarTeam,LookUp(Admin,VarUser.Email=Teamadmin.Email,Team));

     

    In Gallery 
    If(IsBlank(VarTeam),'Refs',Filter('Refs',' Team'=VarTeam.Value))

     

    using .value with the variable 

    Now to add to that, so thanks again and hope this helps someone else

    Sam

  • powerappsrooki Profile Picture
    12 on at

    Hello,

    I am looking out for similar help, I am able to filter the gallery based on user logged in as per below:

    App.OnStart – Set(varUser, User());

    App.Items -  Filter(‘TestSharePointList’, Email = varUser.Email);

    However, I need to show all the records of the gallery when Admin/Specific Users logged in e.g., xyz@abc.com

    Please help! @zmansuri 

    Thanks
    Anmol

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    If(varUser.Email = "xyz@abc.com",TestSharePointList,Filter(‘TestSharePointList’, Email = varUser.Email));

     

    Above code will not filter the gallery if specific user logs in. and if he is not xyz it will filter based on email of user.

    This is simple and hard coded version. You can make it dynamic by making a collection of admin user on on start and in the condition check weather logged in email id is in the collection. You can also make SharePoint list of admins. 

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 Apps

#1
11manish Profile Picture

11manish 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard