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

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Filtering Gallery based on the user login

(0) ShareShare
ReportReport
Posted on by

Hi Everyone 

 

Iam trying to filter my gallery based on the User email = Matches one of the share point Column 

Below I have given the code which I worked on 

But the Gallery is not getting filtered properly.

( Risk_Requestor is a multiline text column ) 

I tried to store email as a variable and tried to apply the same on the formula, but still it's not working. 

and I even tried to remove the filter for the user email and checked the gallery function it working perfectly fine. 

 Onstart :Set(varUserEmail, User().Email)

Items property of Gallery which is not working )*Not showing anyerror

SortByColumns(
Filter(
Risk_Database_1,
LookUp(
Risk_Database_1,
varUserEmail in Risk_requestor,
(
Switch(
varSatgeIndex,
1, Stage_of_risk = "Identification",
2, Stage_of_risk = "Assessment",
3, Stage_of_risk = "Response",
4, Stage_of_risk = "Monitor",
5, Stage_of_risk = "Closed",
true // For varSatgeIndex = 0, show all risks
) &&
If(
Checkbox1_1.Value,
Archetype_head.Email = User().Email,
true
) &&
(
IsBlank(TextInput2.Text) ||
StartsWith('Risk_Title/Summary', TextInput2.Text) ||
StartsWith(Risk_requestor, TextInput2.Text)
)
)
)
),
"Created", SortOrder.Descending
)

 

 

Could anyone please help me to fix this issue? 

I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    151,936 Most Valuable Professional on at
    Re: Filtering Gallery based on the user login

    Hi @Danny_Dicaprio ,

    Firstly, try this

    SortByColumns(
     Filter(
     Risk_Database_1,
     varUserEmail in Risk_requestor &&
     Switch(
     varSatgeIndex,
     1, Stage_of_risk = "Identification",
     2, Stage_of_risk = "Assessment",
     3, Stage_of_risk = "Response",
     4, Stage_of_risk = "Monitor",
     5, Stage_of_risk = "Closed",
     true
     ) &&
     (
     !Checkbox1_1.Value ||
     Archetype_head.Email = User().Email
     ) &&
     ( 
     Len(TextInput2.Text) = 0 || 
     StartsWith(
     'Risk_Title/Summary', 
     TextInput2.Text
     ) || 
     StartsWith(
     Risk_requestor, 
     TextInput2.Text
     )
     )
     ),
     "Created", 
     SortOrder.Descending
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • NPPlatform Profile Picture
    606 Moderator on at
    Re: Filtering Gallery based on the user login

    Hi @Danny_Dicaprio , why do you use the lookup-function? It sounds to me like you want to display a filtered set of records from the Risk_Database_1 in a Gallery. Wouldn't you want to use a formula like:

     

    SortByColumns(
    Filter(
    Risk_Database_1,
    varUserEmail in Risk_requestor,
    Switch(
    varSatgeIndex,
    1, Stage_of_risk = "Identification",
    2, Stage_of_risk = "Assessment",
    3, Stage_of_risk = "Response",
    4, Stage_of_risk = "Monitor",
    5, Stage_of_risk = "Closed",
    true // For varSatgeIndex = 0, show all risks
    ) &&
    If(
    Checkbox1_1.Value,
    Archetype_head.Email = User().Email,
    true
    ) &&
    (
    IsBlank(TextInput2.Text) ||
    StartsWith('Risk_Title/Summary', TextInput2.Text) ||
    StartsWith(Risk_requestor, TextInput2.Text)
    )
    ),
    "Created", SortOrder.Descending
    )

    If that doesn't resolve your problem: what is an example of the content of your multiline text column 'Risk_Requestor'? When something doesn't work for me I try to test the individual components. In this case that would mean

    1. checking whether your variable contains the information you think it does (see image below how to check the contents of variables).
    2. Displaying the text of your SharePoint-column in a label
    3. Checking in a formula whether 'varUserEmail in Label1.Text' equals true. If this doesn't, something in comparing your variable to the SharePoint-column isn't working. If it is true, the problem lies somewhere else. 

    NPPlatform_0-1708596103947.png

     

    Edit: Oh, while writing my response @WarrenBelz already replied. Do try his solution first. 👍

  • Danny_Dicaprio Profile Picture
    on at
    Re: Filtering Gallery based on the user login

    @WarrenBelz 

     

    Thanks 

     

    I really appreciate your response.

    that worked perfectly fine. 

     

    could you please explain why it didn't worked for my formula?

     

    Just One last doubt If I need to add one more filter column for the same email how will I do that  

    will there be any problems if I use filtering in the below format?

    SortByColumns(
     Filter(
     Risk_Database_1,
     varUserEmail in Risk_requestor && varUserEmail in Prime_member 
     Switch(

     

  • Danny_Dicaprio Profile Picture
    on at
    Re: Filtering Gallery based on the user login

    Hi @NPPlatform 

     

    Thanks for the response @WarrenBelz  formula worked perfectly 

    but if some one could explain why it worked in a bit more details , would be great help for my learning 

  • Verified answer
    NPPlatform Profile Picture
    606 Moderator on at
    Re: Filtering Gallery based on the user login

    The LookUp()-function is used to retrieve a single record. The Filter()-function is used to retrieve all records from a datasource that fit the filtercriteria. In your case you wanted multiple results, not only one record. Therefore you didn't need your LookUp()-function.

  • Danny_Dicaprio Profile Picture
    on at
    Re: Filtering Gallery based on the user login

    @NPPlatform   yep Got it 

     

    Thanks for the response 

  • Verified answer
    WarrenBelz Profile Picture
    151,936 Most Valuable Professional on at
    Re: Filtering Gallery based on the user login

    Hi @Danny_Dicaprio ,

    The main issue was this at the top

    LookUp(
     Risk_Database_1,
     varUserEmail in Risk_requestor,

    where you simply only needed the last line. Also there was no closing bracket on the Lookup.

    Your addition will work fine (except you need && at the end) if you need && but I have a feeling you want Or ||, so you would have to bracket that part

    (varUserEmail in Risk_requestor || varUserEmail in Prime_member) &&

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • Verified answer
    NPPlatform Profile Picture
    606 Moderator on at
    Re: Filtering Gallery based on the user login

    @Danny_Dicaprio Regarding using multiple filterconditions: you can do this in different ways. You could do this either in the structure:

     

    Filter(
    Your_Datasource,
    FilterCondition1,
    FilterCondition2,
    FilterCondition3
    )

    Or, what @WarrenBelz did:

    Filter(
    Your_Datasource,
    FilterCondition1 && FilterCondition2 && FilterCondition3
    )

     

    To answer your question: you need to include the && after 'Prime_member', if you do that you're all set.

     

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

Coming soon: forum hierarchy changes

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

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 651 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 385 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 230 Super User 2025 Season 2

Last 30 days Overall leaderboard