web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Counting Lookup Multi-...
Power Apps
Answered

Counting Lookup Multi-select values

(0) ShareShare
ReportReport
Posted on by 14

I'm having trouble counting values in a Lookup field from a SharePoint list that supports multiple values for an app I've created (my first app!).  Is there a way to count the values to see how many instances each of these has had?  The fields are semicolon delimited when viewed in quick edit.

 

Example data:

AgentNameIssues
BobSpelling;Documentation
JoePolicy Violation;Spelling
SamGrammar

 

From this, I would like either a chart or table to get count of the number of Issues in my datasource to have out output like this:

 

IssueCount
Spelling2
Documentation1
Policy Violation1
Grammar1

 

I've managed to count the total number of items, but not a count for each type of issue using the formula found here:

https://powerusers.microsoft.com/t5/Building-Power-Apps/Get-Count-of-values-used-in-Multi-Lookup/m-p/297469#M85755

 

I've tried it with the field as a Choice field with multiple-selection as well with no success either.  Any help or tips you could provide would be greatly appreciated.

Categories:
  • WarrenBelz Profile Picture
    156,750 Most Valuable Professional on at

    HI @WJake ,

    The CountRows function can be used on galleries or other data filtered sets.

    If you tell me exactly what you are trying to do, I can assist.

     

    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.

  • WJake Profile Picture
    14 on at
    Thanks! I am looking to count the instances of each possible value for my Issues field and then place the result into a gallery. I know how to collect data and display it in gallery, but can’t figure out how to get this to count for multi selection fields.
  • WarrenBelz Profile Picture
    156,750 Most Valuable Professional on at

    Hi @WJake ,

    I have just realised what you are after and this is not easy - I assume you want to count inside every field for a total number selected?

    I will admit defeat on this after about 30 minutes of trying many and various things - I will tag my code guru colleague @Anonymous who quite enjoys these challenges.

     

    I will share where I got to if this helps - you can get a Collection with the values in separate fields in a table contained in CollectionName.Value with the items inside this in a field called Result, but to collectively count them is another matter.

    ClearCollect(
     YourCollectionName,
     ForAll(
     YourTableName.YourFieldName,
     Split(
     YourFieldName,
     ","
     )
     )
    )

     

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @WarrenBelz thanks for the tag, this was a tough one. Either that or I've got Sunday brain ...

     

    @WJake 

    Try this on a button then use colIssuesCount as the Items of a gallery to see your count:

    ClearCollect(
     colMultiIssues,
     yourListName.Issues
    );
    Clear(colIssues);
    ForAll(
     colMultiIssues,
     Collect(
     colIssues,
     Filter(
     Choices(yourListName.Issues),
     Value in Issues.Value
     ).Value
     )
    );
    ClearCollect(
     colIssuesCount,
     AddColumns(
     Distinct(
     colIssues,
     Value
     ),
     "Count",
     CountRows(
     Filter(
     colIssues,
     Value = Result
     )
     )
     )
    )

    You can always move this code to the App OnStart or the OnVisible of a screen, the design choice is yours. I tried refactoring this code but couldn't reduce it down but you may be able to do that?

     

    Let me know how you get on.

     

    Note: depending on the size of your SP list you may also need to consider delegation eg I'm not sure if the first ClearCollect above will only look at the first 2000 records?

  • WarrenBelz Profile Picture
    156,750 Most Valuable Professional on at

    @Anonymous - you have risen to the challenge again. My brain on any day of the week would not have got that one.

    @WJake , you have the privilege of a real code expert helping you here.

  • WJake Profile Picture
    14 on at

    @WarrenBelz @Anonymous 

     

    Thanks!  I'm new to powerapps and self taught myself over the past week and couldn't get this one at all.  I had to convert the field from Lookup type to Choices in the Sharepoint list and then this worked without any issues.  I thought out the delegation issues by planning on archiving old data every year when it is no longer needed live which should keep it below the 2000 records.  I'm also creating each department their own list to further prevent going over 2000 records in a given year.

  • WarrenBelz Profile Picture
    156,750 Most Valuable Professional on at

    @WJake ,

    That is the best move you could have made - if you have a few minutes, please read this post that I just finished a few minutes ago.

  • board817 Profile Picture
    3 on at

    Hello,

     

    Thank you for putting this together, I have been able to replicate this using my data, however, I am stuck on that last filter:

     

    Filter(
     colIssues,
     Value = Result
    )

     

    Where is that "Result" coming from? In my app I am getting "Name isn't valid. 'Result' isn't recognized."

     

    Also, when I comment out the "=Result" and run it shows me the list with all equal counts.

     

    I am probably missing something obvious, but I figured I should ask.

     

    Thanks in advance.

  • WarrenBelz Profile Picture
    156,750 Most Valuable Professional on at

    @board817 ,

    That is because since that post, the output of all elements that were Result are now Value.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 271

#3
Mohsin Ali Profile Picture

Mohsin Ali 223

Last 30 days Overall leaderboard