I have a gallery (the source is a SharePoint list) with a checkbox. I have a field User in every item of my gallery. For every User there can be multiple records in a gallery.
On the OnCheck property I collect all checked items into my SelectedItems collection.
After that, I use Collect(UniqueUser, Distinct (SelectedItems, User)) to create a collection of unique Users of my SelectedItems collection.
Question: how can I create a separate collection for every unique user? The nr of unique users is different every time and depends on the checkbox.
Thank you in advance for your help
Solved! Go to Solution.
Hi @comandante ,
Second (or last) one is easy
ClearCollect(
UniqueCollection1,
Filter(
SelectedItems,
User=Last(UniqueUser).Result
)
);
You can however do any number - second one which is not last
ClearCollect(
UniqueCollection1,
Filter(
SelectedItems,
User=Last(FirstN(UniqueUser,2)).Result
)
)
For the third, change the 2 to 3 and so on.
BTW SelectedItems is not a good name for a collection as it is a Reserved Word in Power Apps.
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.
Visit my blog Practical Power Apps
Hi @comandante ,
If I understand you correctly, you would do the same thing to the List, however it is not Delegable
ClearCollect(
UniqueUsers,
Distinct(
SPListName,
User
)
)
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.
Visit my blog Practical Power Apps
Hi @WarrenBelz
Thanks for your respond
This is not exactly what I'm looking for. Let me give you an example
For example: I have checked 2 items in gallery and now I have 2 records in my SelectedItems Collection. Every record has unique User
I tried to use this formula to get them in 2 different collections(this is all I need), but it didn't work
If((First(SelectedItems.User)).User=First(UniqueUser).Result, ClearCollect(UniqueCollection1, ThisItem), ClearCollect(UniqueCollection1, ThisItem));
If I use this formula ClearCollect(UniqueCollection1,Filter(SelectedItems,User=First(UniqueUser).Result));
the first UniqueUser from a collections goes to a separate collection, but how can I get the second one?
And what to do if I have 10 unique users?
Sorry if my questions sounds weird, I'm quite new to PowerApps
Thanks again for your help.
Thanks again!
Hi @comandante ,
Second (or last) one is easy
ClearCollect(
UniqueCollection1,
Filter(
SelectedItems,
User=Last(UniqueUser).Result
)
);
You can however do any number - second one which is not last
ClearCollect(
UniqueCollection1,
Filter(
SelectedItems,
User=Last(FirstN(UniqueUser,2)).Result
)
)
For the third, change the 2 to 3 and so on.
BTW SelectedItems is not a good name for a collection as it is a Reserved Word in Power Apps.
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.
Visit my blog Practical Power Apps
Thank you very much! This works good.
Now I would like to set nr of collections to be created to a variable - Set(UniqColVar, CountA(molUnique)) and
my last question - is there a way I can loop this in ForAll?
Hi @comandante ,
Not really as you cannot dynamically name collections.
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.
Visit my blog Practical Power Apps
User | Count |
---|---|
259 | |
111 | |
97 | |
48 | |
41 |