cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper I
Helper I

Get Count of values used in Multi Lookup

I have a multi lookup field in my sharepoint. 

 

I would like to get the disctinct count of each value used in that field. 

 

For example if I have 2 records:

 

 1. Janet, Steve, Corey

2. Janet, Mike, Corey

 

I need a collection with these values:

 

Name, Count

Janet, 2

Steve, 1

Corey, 2

Mike, 1

 

Is it possible for my PowerApp to generate this collection on load? 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User II
Dual Super User II

Hi @simkessy 

 

To create a collection for your requirement, use the expression:
 
Clear(CountCollection);ForAll(MultiLookupList,ForAll(Persons,If(!(DisplayName in CountCollection.Name),Collect(CountCollection,{Name: DisplayName,Count:1}),Patch(CountCollection,LookUp(CountCollection,Name = DisplayName),{Count:LookUp(CountCollection,Name = DisplayName).Count + 1}))))
 
You can add this expression on "OnVisible" property of your screen. Here, I have created a collection(CountCollection) with two columns(Name, and Count) to store the distinct values. MultiLookupList is the name of My SharePoint list with a column Persons(they have an attribute Display Name to get the person's name) that has the multiple selected persons. So we are applying two loops to iterate over each person selected in every record.  There is an if condition to check if current person already exist in the list. If it exists, it updates the count or else, creates a new record.MicrosoftTeams-image (99).png

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!

View solution in original post

2 REPLIES 2
Dual Super User II
Dual Super User II

Hi @simkessy 

 

To create a collection for your requirement, use the expression:
 
Clear(CountCollection);ForAll(MultiLookupList,ForAll(Persons,If(!(DisplayName in CountCollection.Name),Collect(CountCollection,{Name: DisplayName,Count:1}),Patch(CountCollection,LookUp(CountCollection,Name = DisplayName),{Count:LookUp(CountCollection,Name = DisplayName).Count + 1}))))
 
You can add this expression on "OnVisible" property of your screen. Here, I have created a collection(CountCollection) with two columns(Name, and Count) to store the distinct values. MultiLookupList is the name of My SharePoint list with a column Persons(they have an attribute Display Name to get the person's name) that has the multiple selected persons. So we are applying two loops to iterate over each person selected in every record.  There is an if condition to check if current person already exist in the list. If it exists, it updates the count or else, creates a new record.MicrosoftTeams-image (99).png

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!

View solution in original post

Community Support
Community Support

Hi @simkessy 

 

Could you please reference @yashag2255 's suggestion?

If it works fine,please accept it as solution.

 

Best Regards.

Yumia

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (5,959)