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 / Duplicates in collecti...
Power Apps
Answered

Duplicates in collections, or-filtering not working

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello,

 

I've been stuck on this for a while so I hope this forum can help me! I have a powerapp that collects list items from a sharepoint list into the collection cases and display them in a gallery (it does other things too, but this is the part i'm stuck on). I'll explain briefly how I got here in case there is another obvious solution earlier on i'm not seeing.

 

The problem originally was that clearcollect collected all the list items, but the items have strict permissions on them which gave all our test users "no access" error messages (because they didn't have access to all of the collected list items). I solved this by changing the collection to:

 

 

ClearCollect(Cases;Filter(Events; Status.Value<>"Closed" && Responsible.DisplayName = User().FullName));; 
Collect(Cases;Filter(Events; Status.Value<>"Closed" && Worker.DisplayName = User().FullName));; 
Collect(Cases;Filter(Events; Status.Value<>"Closed" && Author.DisplayName = User().FullName));; 

As having your user in the person-fields Author, Responsible or Worker is what gives permission to the list items (though Flow) this solved the permissions problem (a list item is only collected if the current user is in one of these three fields, which means they have permission to all collected items).

 

 

However this caused duplicates whenever a user is in more than one field at the time.  I looked at the Distinct function, but this would as far as I can tell limit my collection to one table which I don't want. I looked at grouping duplicates together and then degrouping taking only the first of the groups to the new collection but I couldn't get that code to work. I ended up with:

 

ClearCollect(Cases;Filter(Events; And(Status.Value<>"Closed"; Or(Responsible.DisplayName = User().FullName; Worker.DisplayName = User().FullName;Author.DisplayName = User().FullName)))

However this doesn't give me any results at all.

 

So my question:

 

How can I solve this problem? Either by removing duplicates from my collection or getting or-filtering to work in my clearcollect? 

 

Thank you for your time,

Vegard

Categories:
  • Verified answer
    yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hey @Anonymous 

     

    In that case, can you try to update the expression as:
    ClearCollect(Cases;Filter(Events; And(Status.Value<>"Closed"; User().FullName in [Responsible.DisplayName;Worker.DisplayName;Author.DisplayName])))
     
    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
    Microsoft Employee on at

    That worked perfectly, thank you so much for your help! 🙂

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard