cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
simkessy
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
yashag2255
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
yashag2255
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

v-yuxima-msft
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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,370)