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 create a data table...
Power Apps
Unanswered

To create a data table with following sharepoint list

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi!

I have a sharepoint list as shown below, so i want to display a data table (shown as 'result' below). When users filter the drop down filter bar by choosing a choice based on Item[1] column in lists, the app will count the number of times a unique code appears either in Code[1] or Code[2] or Code[3] and display it in the data table, the code with the most count will fall on the top of the table. 

Thanks in advance for any help!

Query.PNG

Categories:
I have the same question (0)
  • victorcp Profile Picture
    2,350 Moderator on at

    Hi,

    One way to what you want is creating a collection with all the codes and then count how many time each one appear in this collection, like this:

     

    Clear(colAux); // the collection that will store all the codes
    
    ForAll(
     Filter(
     SharePointList, // the name of your ShP
     Item = "A" // The filter to select the Item
     ),
     Collect(colAux,{Code:Code1}); // adding code1 to the collection
     Collect(colAux,{Code:Code2}); // adding code2 to the collection
     Collect(colAux,{Code:Code3}); // adding code3 to the collection
    );
    
    ClearCollect(
     colResult, // the result collection
     Sort(
     AddColumns(
     GroupBy( // this will group the same codes
     colAux,
     "Code",
     "Group"
     ),
     "Count",
     CountRows(Group) // and this will count how many time each code appear
     ),
     Count,
     SortOrder.Descending 
     )
    )

     

     

    I hope it helps 🙂

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for the help! I do have another problem, what if i do not want the collection to count when the code is 'N/A'? 

  • victorcp Profile Picture
    2,350 Moderator on at

    You can filter to remove the N/A like this:

    Clear(colAux); // the collection that will store all the codes
    
    ForAll(
     Filter(
     SharePointList, // the name of your ShP
     Item = "A" // The filter to select the Item
     ),
     Collect(colAux,{Code:Code1}); // adding code1 to the collection
     Collect(colAux,{Code:Code2}); // adding code2 to the collection
     Collect(colAux,{Code:Code3}); // adding code3 to the collection
    );
    
    ClearCollect(
     colResult, // the result collection
     Sort(
     Filter(
     AddColumns(
    		GroupBy( // this will group the same codes
     colAux,
     "Code",
     "Group"
     ),
     "Count",
     CountRows(Group) // and this will count how many time each code appear
     ),
     Code <> "N/A" // Removing N/A
     ),
     Count,
     SortOrder.Descending 
     )
    )

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I see thank you so much for the help, may i know if i am using a SharePoint List of more than 2000 items, will i run into any delegation issue running these codes?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Also I need to add the condition of not count those with no values, i tried (Code<>"" ) but it does not work 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I have solved this issue, thanks again

  • victorcp Profile Picture
    2,350 Moderator on at

    it will be an issue if this filter return more than 2000 items, 

     Filter(
     SharePointList, // the name of your ShP
     Item = "A" // The filter to select the Item
     )

     if it returns I suggest add another condition to make sure it will get less than that

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
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#2
11manish Profile Picture

11manish 205 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard