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 Platform Community / Forums / Power Apps / Filter by email and on...
Power Apps
Unanswered

Filter by email and only return first result

(0) ShareShare
ReportReport
Posted on by 969

Dear PowerApps Community

 

I have a SP list with the columns "Title", "employee", "date" and "manager".
This list contains many items with the same employee and manager.

 

In Powerapps, I'd like to show only one entry per employee in a gallery.

 

The idea is to have an employee list filtered to the currently logged in user (manager). Since I don't want to see duplicate employees I need to have this filtered, somehow. I guess the distinct function is the right one for this. However, since I need to access the "date" field as well, how do I achieve that?

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    on at

    Hello @FabianAckeret,

     

    Can you tell us more about your "manager" filed please ? 

    Is it a name ? Is it a mail adress ?

     

    After the filter you do, you can just as you said use the distinct function like that

    Distinct(FutureFilterSource, Employee)

    Keep me informed.

     

    Thank you

  • FabianAckeret Profile Picture
    969 on at

    Hi @Anonymous 

     

    Thanks for your help so far.

     

    The employee and the manager field are people picker fields.

    I'd like to filter and distinct in one Gallery at the same time. If I do distinct, I'll only get one field back.

  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    @FabianAckeret 

     

    Can you try out the below expression:
     
    AddColumns(GroupBy(Filter(SPListName, manager = User().Email),"employee","grouped"),"manager",First(grouped).manager,"date",First(grouped).Date,"Title",First(grouped).Title)
     
    Now, when you want to access the details you can simply use the same column names as per your SP list and this will get only one record per manager and employee.
     
    Hope this Helps!
     
    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
  • Community Power Platform Member Profile Picture
    on at

    Hey,

     

    If I understand rightly, you can process like this (assuming that manager filed is the full name) :

    Distinct(
     Filter(
     DataSource,
    Manager = User().FullName
    ),
    Employee
    )

    Good for you ?

     

    BR,

     

    Louis

  • v-xida-msft Profile Picture
    on at

    Hi @FabianAckeret ,

    Do you want to filter your Employees List based on current login user in manager column, and only display one entry per Employee within the Gallery?

     

    Based on the issue that you mentioned, I think the combination of Filter function, GroupBy function and AddColumns function could achieve your needs.

    I have made a test on my side, please take a try with the following workaround:

    Set the Items property of the Gallery to following formula:

    DropColumns(
     AddColumns(
     GroupBy(
     Filter(
     'YourEmployeeList',
     manager.Email = User().Email
     ),
     "employee",
     "GroupData"
     ),
     "Title",
     First(GroupData).Title,
     "date",
     First(GroupData).date
     "manager",
     First(GroupData).manager
     ),
     "GroupData"
    )

    Then you could display employee, Title, date and manager column value in one entry per employee in your Gallery.

     

    Above formula may cause a Delegation warning issue (the Pesson type column could not be delegated within SP connector), if the amount of your SP List records is not more than 2000, you could ignore this warning issue.

    If the amount of your SP List records is not more than 2000, please take a try with the following workaround:

    1. Set the "Data row limits for Non-delegable queries" option to maximum value -- 2000 within Advanced settings of App settings of your app.

    2. Set the OnStart property of the App control to following:

    ClearCollect(RecordsCollection, 'YourEmployeeList')

    3. Modify above formula within the Items property of the Gallery as below:

    DropColumns(
     AddColumns(
     GroupBy(
     Filter(
     RecordsCollection,
     manager.Email = User().Email
     ),
     "employee",
     "GroupData"
     ),
     "Title",
     First(GroupData).Title,
     "date",
     First(GroupData).date
     "manager",
     First(GroupData).manager
     ),
     "GroupData"
    )

     

    In addition, if the amount of your SP List records is more than 2000, please check and see the alternative solution within the following thread would help in your scenario:

    https://powerusers.microsoft.com/t5/General-Discussion/Pulling-in-large-ish-SQL-tables/m-p/243777#M71518

     

    More details about Delegation in PowerApps, please check the following article:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/delegation-overview

     

    Please take a try with above solution, then check if the issue is solved.

     

    Best regards,

  • FabianAckeret Profile Picture
    969 on at

    @v-xida-msft 

    Thanks for your in-depth answer.

     

    I applied your method, but couldn't get it to work yet. One thing I have to mention to not confuse you completely is that "manager" is actually "responsible" and "date" is "endprobationperiod" :-). This is what I have so far:

     

    DropColumns(
     AddColumns(
     GroupBy(
     Filter(
     'Tasks LM',
     responsible.Email = User().Email
     ),
     "{Name}",
     "GroupData"
     ),
     "employee",
     First(GroupData).employee,
     "Title",
     First(GroupData).Title,
     "endprobationperiod",
     First(GroupData).endprobationperiod,
     "responsible",
     First(GroupData).responsible
     ),
     "GroupData"
    )

    And this is what I see... 

    gallrey.png

     

    There is only one entry of the last in the gallery (the one ending with "ti" in the list. That is why it is only showing one. Otherwise there would be as many as for the other employee ending with "et".

  • v-xida-msft Profile Picture
    on at

    Hi @FabianAckeret ,

    Do you group your filtered result by the '{Name}' column? Based on the formula you provided, I think there is something wrong with it.

     

    Please consider modify your formula as below:

    DropColumns(
     AddColumns(
     GroupBy(
     Filter(
     'Tasks LM',
     responsible.Email = User().Email
     ),
     "{Name}",
    "employee", /* <-- Add formula here. Group your filtered result by {Name} column and "employee" column */ "GroupData" ), "Title", First(GroupData).Title, "endprobationperiod", First(GroupData).endprobationperiod, "responsible", First(GroupData).responsible ), "GroupData" )

     

    If you just want to group your Filtered result by the employee, please modify your formula as below:

    DropColumns(
     AddColumns(
     GroupBy(
     Filter(
     'Tasks LM',
     responsible.Email = User().Email
     ),
     "employee", /* <-- Use "employee" as Group by column rather than "{Name}" column */
     "GroupData"
     ),
     "Title",
     First(GroupData).Title,
     "endprobationperiod",
     First(GroupData).endprobationperiod,
     "responsible",
     First(GroupData).responsible
     ),
     "GroupData"
    )

    Please take a try with above solution, check if the issue is solved.

     

    Best regards,

  • FabianAckeret Profile Picture
    969 on at

    @v-xida-msft thanks again for your answer!

     

    I am not able to write "employee" for the column name of the GroupBy function. It's not selectable. What I have though is "OData__IsRecord". However, when I choose "OData__IsRecord" it will return only 1 result.

    My code looks like below:

     

    DropColumns(
     AddColumns(
     GroupBy(
     Filter(
     'Tasks LM',
     responsible.Email = User().Email
     ),
     "OData__IsRecord",
     "GroupData"
     ),
     "employee",
     First(GroupData).employee,
     "Title",
     First(GroupData).Title,
     "endprobationperiod",
     First(GroupData).endprobationperiod,
     "responsible",
     First(GroupData).responsible
     ),
     "GroupData"
    )
  • v-xida-msft Profile Picture
    on at

    Hi @FabianAckeret ,

    If the "employee" is a Person type column (Complex type column) in your SP list, you could not use it as group by column in your GroupBy formula.

     

    Based on the issue that you mentioned, I think the AddColumns function could achieve your needs. Please consider modify your formula as below:

    DropColumns(
     AddColumns(
     GroupBy(
     AddColumns(
    Filter( 'Tasks LM', responsible.Email = User().Email ),
    "EmployeeName", /* <-- Add a new column to your Filtered list based on the employee column, then use the new added column ("EmployeeName") as Group by column */
    employee.DisplayName
    ), "EmployeeName", "GroupData" ), "employee", First(GroupData).employee, "Title", First(GroupData).Title, "endprobationperiod", First(GroupData).endprobationperiod, "responsible", First(GroupData).responsible ), "GroupData" )

    Please take a try with above solution, then check if the issue is solved. Within your Gallery, you could use the following formula to get the display name of the employee directly:

    ThisItem.EmployeeName

     

    Best regards,

  • Community Power Platform Member Profile Picture
    on at

    Hi @FabianAckeret how are you progressing with this?

     

    @Anonymous 

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 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard