cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
KimberlyM
Level: Powered On

Gallery: Filter this or that or that... + Sort by 1 of 4 options + if specific user display All! Oh my!

I am on my last step to finishing my app and I am finding it a doozy.

What I want is to:

1. Filter by AssignedTo OR LeadMember1 OR LeadMember2 OR LeadMember3 OR LeadMember4
//These choices are all dropdown selections made on my edit screen

2. Sort by a dropdown selection based on 4 different columns in my Lead_Data SharePoint List. 

//These column choices are Date (Date to be default sort), AssignedTo, Status and LeadMembers (1 through 4)

3. Allow my admin users (defined in SharePoint List "Admin_LeadData"), to see ALL entries in the gallery.

 

I have been successful in filtering AssignedTo, "Filter(Lead_Data, AssignedTo.Value = varUser)", but all the other help I can find relates to filter by this AND this instead of the OR that I need in this situation.

 

Capture.JPG

3 ACCEPTED SOLUTIONS

Accepted Solutions
Super User
Super User

Re: Gallery: Filter this or that or that... + Sort by 1 of 4 options + if specific user display All! Oh my!

Here is how you would do the "Or" with the with the varUser:

 

Filter(Lead_Data, AssignedTo.Value = varUser || LeadMember1.Value = varUser || LeadMember2.Value = varUser || LeadMember3.Value = varUser || LeadMember4.Value = varUser)



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
Super User
Super User

Re: Gallery: Filter this or that or that... + Sort by 1 of 4 options + if specific user display All! Oh my!

If you want all the items to show if the person is an Admin and just filter if the use isn't an Admin then try this formula:

 

If(Admin_LeadData.FullName = varUser, Lead_Data

Filter(Lead_Data, AssignedTo.Value = varUser || LeadMember1.Value = varUser || LeadMember2.Value = varUser || LeadMember3.Value = varUser || LeadMember4.Value = varUser))



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
Community Support Team
Community Support Team

Re: Gallery: Filter this or that or that... + Sort by 1 of 4 options + if specific user display All! Oh my!

Hi @KimberlyM ,

Is Admin_LeadData a list name and FullName a field name?

If so, the reason why you met this problem is that Admin_LeadData.FullName means a table of one column, while varUser is a text type. You could not compare them directly.

So I suggest you try this:

If(!IsEmpty(Filter(Admin_LeadData,FullName = varUser)) ,   //justify whether has a record that fullname is the same as varUser
Lead_Data, ......)

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
6 REPLIES 6
Super User
Super User

Re: Gallery: Filter this or that or that... + Sort by 1 of 4 options + if specific user display All! Oh my!

Here is how you would do the "Or" with the with the varUser:

 

Filter(Lead_Data, AssignedTo.Value = varUser || LeadMember1.Value = varUser || LeadMember2.Value = varUser || LeadMember3.Value = varUser || LeadMember4.Value = varUser)



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
KimberlyM
Level: Powered On

Re: Gallery: Filter this or that or that... + Sort by 1 of 4 options + if specific user display All! Oh my!

@Jeff_Thorpe Thank you! This has me well on my way! I googled what the || means so I now know it means 'OR', instead of just assuming it mean 'OR'. Thanks!

Can you lead me a little more... I am loving learning PowerApps. 

In this I am thinking if you are logged in as one of the admin users and your user full name matches the sharepoint list full name then do not filter anything. Else filter by the user logged in... etc. 

#1
If(Admin_LeadData.FullName = varUser, !Filter(), Filter(Lead_Data, AssignedTo.Value = varUser || LeadMember1.Value = varUser || LeadMember2.Value = varUser || LeadMember3.Value = varUser || LeadMember4.Value = varUser))

Or my thought process was also if your user does not match someone listed in the admin sharepoint list then filter, else do nothing.

#2
If(Admin_LeadData.FullName = !varUser, Filter(Lead_Data, AssignedTo.Value = varUser || LeadMember1.Value = varUser || LeadMember2.Value = varUser || LeadMember3.Value = varUser || LeadMember4.Value = varUser))

 

I believe #2 is more accurate as I have only an error for the '=' that states that it is an invalid argument but adding '.Value' to the end of 'Admin_LeadData.FullName' or 'varUser' makes the statement angrier.

Can you help me understand where or why my thinking is incorrect. Thank you!

Super User
Super User

Re: Gallery: Filter this or that or that... + Sort by 1 of 4 options + if specific user display All! Oh my!

If you want all the items to show if the person is an Admin and just filter if the use isn't an Admin then try this formula:

 

If(Admin_LeadData.FullName = varUser, Lead_Data

Filter(Lead_Data, AssignedTo.Value = varUser || LeadMember1.Value = varUser || LeadMember2.Value = varUser || LeadMember3.Value = varUser || LeadMember4.Value = varUser))



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
KimberlyM
Level: Powered On

Re: Gallery: Filter this or that or that... + Sort by 1 of 4 options + if specific user display All! Oh my!

@Jeff_Thorpe, makes complete sense, don't know why I didn't think of it as it reads like speaking English. However, I still don't understand why in this part of the function

If(Admin_LeadData.FullName = varUser, Lead_Data, 

the '=' is an 'invalid argument type'. My Admin_LeadData, FullName, is a 'Single line of text' and my varUser is defined onStart of the App as 'Set(varUser, User().FullName);'. I learned previously that when this happens usually '.Value' fixes this problem but in this case it makes it much angrier. Why?

Community Support Team
Community Support Team

Re: Gallery: Filter this or that or that... + Sort by 1 of 4 options + if specific user display All! Oh my!

Hi @KimberlyM ,

Is Admin_LeadData a list name and FullName a field name?

If so, the reason why you met this problem is that Admin_LeadData.FullName means a table of one column, while varUser is a text type. You could not compare them directly.

So I suggest you try this:

If(!IsEmpty(Filter(Admin_LeadData,FullName = varUser)) ,   //justify whether has a record that fullname is the same as varUser
Lead_Data, ......)

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Super User
Super User

Re: Gallery: Filter this or that or that... + Sort by 1 of 4 options + if specific user display All! Oh my!

@KimberlyM ,

 

The Lead_Data after the Admin = current user logic is returning the data from the data source unfiltered. You only use the Filter() if you need to filter the data source by some conditions. 



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 219 members 4,918 guests
Please welcome our newest community members: