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 / Trying To Find Highest...
Power Apps
Unanswered

Trying To Find Highest Picked Item

(0) ShareShare
ReportReport
Posted on by 138

Hello…I have an app where people pick a category and then the associated type for help.  I log the selections they make in a separate Sharepoint list that records what category and then what type each time they search. What I would like to do is find the highest searched for items in the log table and list it on the screen as in…

”The most commonly searched for Cat and Type this month is…”

 

is there a way I can see the highest counts of that cat and type for that month and then list it.  Ultimately I’d love to see a rating system of the top 2 or 3 most commonly searched for things. I’m guessing it’s like a score type of thing, but I’m not sure how to go about it

 

THANKS

Categories:
  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Roystreet,

     

    Great idea to implement a top searched for functionality in the app. Below I will explain the code step by step, since it is a rather extensive code snippet. (See step 3 for complete code)

     

    (1) Create a delegable Filter() to only display the current month's searches:

    With(
     {
     wStartOfMonth: DateTime(
     Year(Today()),
     Month(Today()),
     01,
     0,
     0,
     0
     ),
     wEndOfMonth: DateTime(
     Year(Today()),
     Month(Today()) + 1,
     0,
     23,
     59,
     59
     )
     },
     Filter(
     //Change to correct list name
     ListName,
     Created >= wStartOfMonth && Created <= wEndOfMonth
     )
    )

     

    (2) Group the rows based on a column value (example is based on Title) and display the amount of records that matches the grouped value

    //Add a row displaying the count
    AddColumns(
     //Group by Title
     GroupBy(
     //With function mentioned above
     With(),
     "Title",
     "GroupedRecords"
     ),
     "CategoryCount",
     CountRows(GroupedRecords)
    )

     

    Important remark: The code above is based on grouping a text field. Should Category be a choice field, then you will need to add an AddColumns around the With function:

    //Add a row displaying the count
    AddColumns(
     //Group by category text value
     GroupBy(
     AddColumns(
     //With function mentioned above
     With(),
     //Add a text value column
     "CategoryTextVal",
     //Change to the correct category column name
     CategoryColumn.Value
     ),
     "CategoryTextVal",
     "GroupedRecords"
     ),
     "CategoryCount",
     CountRows(GroupedRecords)
    )

     

    (3) Sort descendingly based on the new Count column and only display the top 3 searches (Complete code)

    FirstN(
     Sort(
     AddColumns(
     GroupBy(
     With(
     {
     wStartOfMonth: DateTime(
     Year(Today()),
     Month(Today()),
     01,
     0,
     0,
     0
     ),
     wEndOfMonth: DateTime(
     Year(Today()),
     Month(Today()) + 1,
     0,
     23,
     59,
     59
     )
     },
     Filter(
     //Change to correct List Name
     ListName,
     Created >= wStartOfMonth && Created <= wEndOfMonth
     )
     ),
     //Change to category column (See step 2 remark on choice columns)
     "Title",
     "GroupedRecords"
     ),
     "CategoryCount",
     CountRows(GroupedRecords)
     ),
     //Display the highest counts first
     CategoryCount,
     SortOrder.Descending
     ),
     //Display the first 3 records
     3
    )

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • Roystreet Profile Picture
    138 on at

    Thank you very much, I haven't had time to test it just yet, sorry about the delayed response.  I look forward to trying it out

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 395 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard