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 / Filtering gallery by u...
Power Apps
Answered

Filtering gallery by unique username(Office365)

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello everyone,

 

Wasn't sure where to post this so will do in this section.

 

I have a Sharepoint list as my database origin, as seen here:

forum_help_1.png

 

It has as title the project name (Project 1,2,3), daysDIFF of the difference in days of start date and end date, name of task (tarea1,2,3), start date, end date, real end date, person responsible of task (this is with office365 accounts) and comment.

 

I have already a DISTINCT in the dropdown list:

f1.png

 

I use that one as filter in the Gallery and ordered by the end date ("Fecha Termino"):

f2.png

 

Now, as a final filter, I need to show ONLY those of which the user who is seeing the application is in the column "Encargado" of the Sharepoint list, which has people's name using Office365 accounts (and their emails).

Is there any way to filter by using User().Email / Fullname and comparing it to the ones on the sharepoint list, and thus show only those of the user viewing the app?

 

Any help would be greatly appreciated.

 

Thanks in advance,

Categories:
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous  give this a try in your filter.

     

       SortByColumns(Filter(demo_project; Título=ListaPryectos.Selected.Value && User().Email in ShowColumns(Encargado, "Email")); "Fecha_x0020_Termino";If(SortDescending1;Descending;Ascending))

     

    The simplicity of this is that it is turning the Encargado field into a single column table of emails and then just throwing the "In" operator at it.

     

    Hope this helps.  ¡Buena suerte!

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Ok but what happens when they reach more than 500 records, as it won't be able to filter the records anymore past the limit set for the App - 'in' is not currently a delegable command for SharePoint 🙂

    Additionally, @Anonymous is comparing whether the values are identical (does their email = that email in the column), so there's no need for an 'in' when the values need to be equal 🙂

     

    For filtering efficiency purposes, you should set a variable 'UserEmail' in the App's OnStart (as we don't want it calling the User().Email Function every time for each and every every record it is checking against:

    Set(UserEmail, User().Email)

    This way it is only referencing a local variable when doing comparisons during the filtering, which will be a lot faster.

     

    Then we slightly tweak the formula:

     

    SortByColumns(
                              Filter(

                                        demo_project;

                                        Título=ListaPryectos.Selected.Value

                                           &&

                                        Encargardo = UserEmail
                               );
                              "Fecha_x0020_Termino";
                              If(
                                  SortDescending1;
                                  Descending;
                                  Ascending
                              )
    )

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RandyHayes 

    Your solution works for what I wanted, thank you. However, it gives the warning of the yellow triangle of delegation. Is there any way to solve that?

     

    @iAm_ManCat 

    Your solution, sadly, didn't work for me. Maybe as another way? As to avoid the delegation problem.

    The column in Sharepoint that has the people in it, is both name and email since it is linked to office365 accounts, so maybe it is that?

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @iAm_ManCatthe original question dealt with Multiple people in the people column.  This was evident in the picture showing the data source from SharePoint. Smiley Wink  If you look at the second record, you will see two names listed in the Encargado column. Thus, an equality operator will not work in this case and the use of the In operator was necessary.

    As well, the Encargado column is a people column and thus is not an email address with which to do an equality comparison to UserEmail.  You would need to compare against Encargado.Email...which is not delegable. Smiley Embarassed

     

    @Anonymousunfortunately, there is not a good work around for the delegation issue on that type of field.  First, consider if you will be dealing with more than 500 records in that list.  If not, then ignore the delegation warning.

    If so, then you will need to consider alternate methods, either at your dataSource (SharePoint), or through local Collections.  

    If through SharePoint, you will need to abandon the use of the Person type column, or at least augment the column with another column that is a string type (as some formulas for SharePoint can be delegated).  This could be a challenge for the multiple selection feature you are using.

    If through local Collections, then you will need to gather all the records to a local collection and then you can filter against that without delegation issues.  However, there are additional challenges that come along with that patterns.

     

    Hope this is helpful.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you so much @RandyHayes

    It does work, like I think I said before (if I didn't, saying it now), and regarding the delegation problem, I think that I won't have more than 500 users. If I did have, could you link me some documentation to see the local collection topic? I am kind of (very) new to PowerApps, so don't know much of it yet but am discovering by doing, so to speak 😛

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    No problem.  I don't have a specific link to point to for details on collecting locally to avoid delgation issues.  I tend to find it is very specific to your needs in each case. But, certainly if you run into the need, feel free to reach out direct or post again.

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

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard