cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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 III
Dual Super User III

Re: Get Count of values used in Multi Lookup

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 III
Dual Super User III

Re: Get Count of values used in Multi Lookup

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

Highlighted
Community Support
Community Support

Re: Get Count of values used in Multi Lookup

Hi @simkessy 

 

Could you please reference @yashag2255 's suggestion?

If it works fine,please accept it as solution.

 

Best Regards.

Yumia

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,700)