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 / Count or CountIf by us...
Power Apps
Answered

Count or CountIf by using SP multiselect person column

(0) ShareShare
ReportReport
Posted on by 62
Hi Everyone,
I have a simple SP list R3_RegionalEventsCalendar with the following fields:
Title - text;
Date - datetime field;
Employee - multi select person field 

Task: count the number of events for each employee. That is, if two employees are added to the Event1 event, then each of them must be credited with one event.
It's not the first day that I've been scratching my head... I can't figure it out..

When the Employee field did not support multiselect, I solved it as follows and everything worked. 
I added to the screen HTML text control and insert following code:
"<table style='width: 100%; border-collapse: collapse;'>
    <thead>
        <tr>
            <th style='background-color: #4F81BD; color: white; border: 1px solid #1e1e1e; padding: 5px; text-align: center;'>Employee</th>
            <th style='background-color: #4F81BD; color: white; border: 1px solid #1e1e1e; padding: 5px; text-align: center;'>EventsCount</th>
        </tr>
    </thead>
    <tbody>" &
    Concat(
        Sort(
            AddColumns(
                Distinct(R3_RegionalEventsCalendar, Employee.DisplayName),
                EventCount, 
                CountIf(R3_RegionalEventsCalendar, Employee.DisplayName = Value)
            ),
            EventCount, SortOrder.Descending
        ),
        "<tr>
            <td style='border: 1px solid #1e1e1e; padding: 5px; text-align: center;'>" & Value & "</td>
            <td style='border: 1px solid #1e1e1e; padding: 5px; text-align: center;'>" & 
            EventCount & 
            "</td>
        </tr>"
    ) &
    "</tbody>
</table>"
And as a result I got this table:
 
But when I added the multiselect option - of course it didn't work.
Any help would be appreciated!
Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,963 Most Valuable Professional on at
    Try this for a start
    Sort(
       RenameColumns(
          AddColumns(
             GroupBy(
                Ungroup(
                   R3_RegionalEventsCalendar,
                   Employee
                ),
                DisplayName,
                Grouped
             ),
             EventCount,
             CountRows(Grouped)
          ),
          DisplayName,
          Employee
       ),
    EventCount,
    SortOrder.Descending

    )
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • Kalakosha Profile Picture
    62 on at
    Hi @WarrenBelz,
    thanks for responding to my post.
     
    I tried pasting your code into my HTML block.
    each line is underlined in red...
     
    The function 'Sort' has some invalid arguments.
    Invalid argument type. Expecting one of the following: Text, Number, Decimal, Date, Time, DateTimeNoTimeZone, DateTime, Boolean, ViewValue, UntypedObject.
     
    Invalid argument type. Expecting one of the following: Text, Number, Decimal, Date, Time, DateTimeNoTimeZone, DateTime, Boolean, ViewValue, UntypedObject.
    The function 'RenameColumns' has some invalid arguments.
  • WarrenBelz Profile Picture
    156,963 Most Valuable Professional on at
    Please see amended code - free-typed and I had the bottom part in the wrong order. Also please put it in a Gallery or Data Table first to be satisfied you have the correct data.
  • Kalakosha Profile Picture
    62 on at
    Thank you, it works great with the gallery and most importantly, it keeps the count correctly.
    You are a magician!

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 221 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 120

Last 30 days Overall leaderboard