web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

Gallery filtering

(0) ShareShare
ReportReport
Posted on by 559

Hi All,

I have a gallery which should filter based on the User logged in. When the user logged in, is a Project Manager or any people in the manager criteria it has to filter only their respective projects. I have a search text input box(search text) and a Combo box(cs dropdown) as filter boxes. 

When the Project Manager logs in their respective projects is getting displayed. when the CS Combo box value is selected their respective projects is getting displayed. But I have a requirement where when the user logs in and select some other name in the CS combo box it must display all the projects with the selected person name. I tried with few possibilities but its not working. 

The code on the Items gallery is :

Filter(
ProjectMaster_List,
(ProjectManager.DisplayName = varCurrentuser && ProjectStatus.Value = "Active") || ('DelEx Consultant'.Value = varCurrentuser && ProjectStatus.Value = "Active"),
If(
Is Blank(SearchBoxShp.Text),
true,
SearchBoxShp.Text in ProjectName || SearchBoxShp.Text in DDName.DisplayName || SearchBoxShp.Text in DMName.DisplayName || SearchBoxShp.Text in 'Vertical Sales Head'.DisplayName || SearchBoxShp.Text in ProjectManager.DisplayName || SearchBoxShp.Text in Practice. Value || SearchBoxShp.Text in AccountName1
) && If(
Is Blank('CS Combo box'.Selected.Value),
true,
'CS Combo box'.Selected.Value in 'DelEx Consultant'. Value

)

I added another And condition and gave !Is Blank('CS Combo box'.Selected.Value) the gallery filtering and combo box is not working properly.

Any help/suggestions on this.

Thanks in advance.

Categories:
I have the same question (0)
  • MissingLink Profile Picture
    236 on at

    I think that you are only looking at the CURRENT user ? 

    (ProjectManager.DisplayName = varCurrentuser && ProjectStatus.Value = "Active") || ('DelEx Consultant'.Value = varCurrentuser && ProjectStatus.Value = "Active"),

    Try changing the above line to 

    (ProjectManager.DisplayName = varCurrentuser && ProjectStatus.Value = "Active") || ('DelEx Consultant'.Value = CS ComboBox.Selected.Value && ProjectStatus.Value = "Active"),

     

  • Sri Profile Picture
    559 on at

    @MissingLink 

    If I give in the above way as you mentioned even the logged in user values is not filtering and listing certain different projects.

  • Verified answer
    MissingLink Profile Picture
    236 on at

    I am assuming that varCurrentuser is being set when the app is opened.

    I would consider creating a different variable so that you can change the 'user' for when you filter. 

    So when THE APP STARTS, add this just after you set varCurrentUser.

     

    UpdateContext({varDelegate:User().FullName});

     

    So now, in the on change event of the  CS ComboBox, reset the varDelegate

    UpdateContext({varDelegate:[CS ComboBox].Selected.FullName});

    so that the filter will apply in the gallery as follows.

    (ProjectManager.DisplayName = varDelegateuser && ProjectStatus.Value = "Active") || ('DelEx Consultant'.Value = varDelegateuser && ProjectStatus.Value = "Active"),

     

    You will want to reset varDelegate back to the current user at some point.

     

  • Sri Profile Picture
    559 on at

    @MissingLink 

    I have given the Set variable on the App ON start. It must work as when user logged in is a PM their projects must display. When any one of the person from the CS Combo box logs in their projects must display. And when logged in user select any value from the Combo box it must display the Combo box selected value also.

    I hope now you get an idea of the scenario.

  • Sri Profile Picture
    559 on at

    @MissingLink ,

    I guess it is working but as you told to Reset the Var Delegate. If the given the Reset function in the On change its giving an error. 

    Where should I give this both conditions On APP On start or Combo box On Change.

    UpdateContext({varDelegate:User().FullName});
    UpdateContext({varDelegate:[CS ComboBox].Selected.FullName});

     

  • MissingLink Profile Picture
    236 on at

    (You second comment came in while I was typing, so I'll answer both here.)

    So just to be clear. 

    If I log in, then I see my projects by default.

    If you log in, then you see your projects by default.

     

    But, If I want to see your projects, then I select your name from the combo and then what should I see ?

    A. Both of our projects  (varCurrentUser and also varDelegateuser) or

    B. Only your projects (varDelgareuser only)

     

    In the App On Start,  you are setting varCurrentuser. 

    However, If you want filter by another user (for either A or B above) then it's probably best to set that in another variable, so that the varCurrentuser stays constant for the whole app.

    So when the app starts, you may as well set varDelegate to be the same as varCurrentuser

     

    So the filter should return only the varCurrentuser records before you select from the combobox.

     

    Then when you select the other user from the combo, the OnChange event will update the varDelegate.

    That way, this condition will look for both the varCurrentser AND the varDelgateuser.

    To test, I would comment out the rest of the filter and only use this as a starting point.

    Filter(
    ProjectMaster_List,
    (ProjectManager.DisplayName = varCurrentuser && ProjectStatus.Value = "Active") || (ProjectManager.DisplayName = varDelgateuser && ProjectStatus.Value = "Active"))

    You will probably need to play with this concept a little to get it working correct.

     

    Then when you know that the first part of the filter is working, add the rest of the filter conditions - piece by piece.

     

    By the way - I think there is a problem with the following:

    Filter(
    ProjectMaster_List,
    	(ProjectManager.DisplayName = varCurrentuser && ProjectStatus.Value = "Active") || ('DelEx Consultant'.Value = varCurrentuser && ProjectStatus.Value = "Active"),
    If(

     I think it should have a 'And' just before the 'If('

    Filter(
    ProjectMaster_List,
    	(ProjectManager.DisplayName = varCurrentuser && ProjectStatus.Value = "Active") || ('DelEx Consultant'.Value = varCurrentuser && ProjectStatus.Value = "Active") And
    If(

     - like this 

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard