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 / To count the number of...
Power Apps
Answered

To count the number of codes (either 1 or 2) showing up when an item (either 1 or 2) is searched

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi!

I have a PowerApps linked to a sharepoint list, the general idea is to count the number of codes (either 1 or 2) showing up when an item (either 1 or 2) is searched, and put them in a table in descending order. The illustration shown below shows the example of the sharepoint list, if the user were to search 4567, the app has to find any rows that contains 4567 (from either the item[1] or item[2] column) and count the number of each code appearing (either from code[1] or code[2] column). The resulting code with the highest count should be plotted in a table in descending count order as shown below. Thank you in advance for any help!

 

Capture.PNG

Categories:
I have the same question (0)
  • Verified answer
    CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Anonymous You can set this in the OnChange property of the search TextInput,

    With({_codes:ShowColumns(Filter(SPItemsList,Item1=Value(TextInput.Text) || Item2=Value(TextInput8.Text)),"Code1","Code2")},
     With({
     _code1:RenameColumns(ShowColumns(_codes, "Code1"), "Code1", "Code"),
     _code2:RenameColumns(ShowColumns(_codes, "Code2"), "Code2", "Code") 
     },
     ClearCollect(colCodeCount,GroupBy(ClearCollect(colCodes, _code1, _code2), "Code", "Count"))
     )
    )

    Set the Items property of the DataTable to colCodeCount and 2 Fields to the DataTable, the First will be "Code" and the second will be "CountRows(ThisItem.Count)"

     

    Please remember to give a 👍 and accept my solution as it will help others in the future.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for the help, in addition, what if i do not want to count certain codes such as "N/A"?

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Anonymous In the Filter you can add a condition like, 

    Item1<>"N/A"

     

    Please remember to give a 👍 and accept my solution as it will help others in the future.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi! What if i want to filter the 'code' column, if its 'N/A' it will not count and appear in the data table? Thank you!

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 483

#2
WarrenBelz Profile Picture

WarrenBelz 399 Most Valuable Professional

#3
11manish Profile Picture

11manish 327

Last 30 days Overall leaderboard