cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
simkessy
Level: Powered On

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

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

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

Community Support Team
Community Support Team

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
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 403 members 2,948 guests
Please welcome our newest community members: