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 based o...
Power Apps
Unanswered

Filter Gallery based on selection and user

(0) ShareShare
ReportReport
Posted on by 172

I have several data sources in my app.  One list has departments and people.  My app has some filters already set on the gallery but I would like to PRE-FILTER the list based on Department and to the user within that department. 

 

Filter(
     'Receiving Requests',
    Len(drptypeDepartment_1.Selected.Value) = 0 || Department.Value = drptypeDepartment_1.Selected.Value,
    Len(cmbAssignedTo_1.Selected.DisplayName) = 0 || AssignedTo.DisplayName = cmbAssignedTo_1.Selected.DisplayName,
    Len(TxtPO.Text) = 0 || StartsWith(
        'PO#',
        TxtPO.Text
    ),
    Len(TxtID.Text) = 0 || StartsWith(
        ID,
        TxtID.Text
    )
)
 
This the my current filter and it works great!  Below is my app.  The two fields in the other list are Department and Receiver.  As always any help is appreciated.
Sonia316_0-1706107722009.png

 

Categories:
  • CU18061035-1 Profile Picture
    18 Microsoft Employee on at

    hey @Sonia316 

     

    please try this approach:

     

    Filter(
     'Receiving Requests',
     Department.Value = CurrentUserDepartment, // Pre-filter based on user's department
     Len(drptypeDepartment_1.Selected.Value) = 0 || Department.Value = drptypeDepartment_1.Selected.Value,
     Len(cmbAssignedTo_1.Selected.DisplayName) = 0 || AssignedTo.DisplayName = cmbAssignedTo_1.Selected.DisplayName,
     Len(TxtPO.Text) = 0 || StartsWith('PO#', TxtPO.Text),
     Len(TxtID.Text) = 0 || StartsWith(ID, TxtID.Text)
    )

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • Sonia316 Profile Picture
    172 on at

    Is the currentuserdepartment a variable?

  • Sonia316 Profile Picture
    172 on at

    I'm using this to set my variable but it's not working

    Set(CurrentUserDepartment, !IsBlank(LookUp(Receivers,User().Email in Receiver.Department)))
  • CU18061035-1 Profile Picture
    18 Microsoft Employee on at

    yes its a variable.

     

    where do u store the department information?

     

    here are a few examples:

     

    Set(CurrentUserDepartment, Office365Users.MyProfile().Department)

    or

    Set(CurrentUserDepartment, Lookup(UsersList, User.Email = User().Email).Department)

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • Sonia316 Profile Picture
    172 on at

    Sorry I got sick mid-week and I'm just getting back to it.  The variable works but I am getting this error in my filter.

     

    It does not like the = in the first filter.

     

    Filter(
         'Receiving Requests',
        Department.Value = CurrentUserDepartment,
        Len(drptypeDepartment_1.Selected.Value) = 0 || Department.Value = drptypeDepartment_1.Selected.Value,
        Len(cmbAssignedTo_1.Selected.DisplayName) = 0 || AssignedTo.DisplayName = cmbAssignedTo_1.Selected.DisplayName,
        Len(TxtPO.Text) = 0 || StartsWith(
            'PO#',
            TxtPO.Text
        ),
        Len(TxtID.Text) = 0 || StartsWith(
            ID,
            TxtID.Text
        )
    )
  • CU18061035-1 Profile Picture
    18 Microsoft Employee on at

    hey @Sonia316 

     

    can you please try this:

    Filter(
     'Receiving Requests',
     Department.Value = CurrentUserDepartment,
     Len(drptypeDepartment_1.Selected.Value) = 0 || Department.Value = drptypeDepartment_1.Selected.Value,
     Len(cmbAssignedTo_1.Selected.DisplayName) = 0 || AssignedTo.DisplayName = cmbAssignedTo_1.Selected.DisplayName,
     Len(TxtPO.Text) = 0 || StartsWith(
     'PO#',
     TxtPO.Text
     ),
     Len(TxtID.Text) = 0 || StartsWith(
     ID,
     TxtID.Text
     )
    )

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • Sonia316 Profile Picture
    172 on at

    Still doesn't like the = in the 

    Department.Value = CurrentUserDepartment,

     

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 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 194 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 150

Last 30 days Overall leaderboard