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 / Filtering Grouped Data...
Power Apps
Answered

Filtering Grouped Data from Sharepoint List

(1) ShareShare
ReportReport
Posted on by 57

Hello everyone!

 

I'm hoping someone can help me out as I've been banging my head against the wall trying to figure this out.

 

I am building a Uniform Order app and am working on sorting the data. A Sharepoint list is my database and each record in the list is one item of an order. I have the front-end set up so that multiple items can be ordered and will create individual records but will all have the same OrderID to allow for grouping.

 

Here's my issue. In the backend 'admin' area of the app I have two galleries. The first displays the information from the Order List GroupedBy OrderID and when selected displays the individual items from the order in the second gallery. I have a radio button for the first gallery that filters the data by either Active or Completed orders. My problem is how I want the data sorted.

I want an Active order to include all items that have been ordered with their various statuses (Received, On Order, Partially Filled, Filled). However, I only want the Completed order section to include orders that have ALL their items with a status of Filled. 

 

I have been using the GroupBy function which has been working perfect for grouping the OrderIDs together, but I can't seem to get the second piece of the puzzle down which would be sorting the Grouped Data to display only if the Order Status for all the items within that Grouped Data is Filled.

 

Any ideas?

 

Thanks in advance,

Shawn

Categories:
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @ShawnSchinkel 

    Please post your current code for the items properties of both galleries.

  • ShawnSchinkel Profile Picture
    57 on at

    Hi @Drrickryp , thanks for responding!

     

    Here is the code for the first gallery which takes the data from the Sharepoint list and filters it down based on a Radio button and/or Person ComboBox depending on if it's blank or has a selection. I've shortened out some of the code as a bunch of it is mostly duplicated with slightly different filtering depending on the radio button value.

     

    If(

    Radio1.Selected.Value = "Complete" && IsBlank(ComboBox1),
    SortByColumns(
    GroupBy(
    Filter(
    Clothing_Order_List,
    OrderStatus = "Filled"
    ),
    "OrderID",
    "GroupedOrders"
    ),
    "OrderID",
    Descending
    ),
    Radio1.Selected.Value = "Complete",
    SortByColumns(
    GroupBy(
    Filter(
    Clothing_Order_List,
    OrderStatus = "Filled",
    Name.DisplayName = ComboBox1.Selected.DisplayName
    ),
    "OrderID",
    "OrderStatus",
    "GroupedOrders"
    ),
    "OrderID",
    Descending
    )
    )

     

    The second gallery also completes filtering based on the Radio Button selection but also uses a variable which is updated when the first gallery item is selected.

     

    If(
    Radio1.Selected.Value = "All",
    Filter(
    Clothing_Order_List,
    Name.DisplayName = varGalleryThisItem.Name.DisplayName
    ),
    Radio1.Selected.Value = "Active",
    Filter(
    Clothing_Order_List,
    Name.DisplayName = varGalleryThisItem.Name.DisplayName,
    Or(
    OrderStatus = "Submitted",
    OrderStatus = "Received",
    OrderStatus = "Ordered",
    OrderStatus = "Partially Filled"
    )
    ),
    Radio1.Selected.Value = "Complete",
    Filter(
    Clothing_Order_List,
    Name.DisplayName = varGalleryThisItem.Name.DisplayName,
    OrderStatus = "Filled"
    )
    ).

     

    I'm not sure if it's doable but I would like the first gallery to only show the orders in the "Completed" section that have all of their grouped items marked as complete. An order may have four items with only one of them being filled so the order should still remain active. I've added a screenshot that shows the layout, you can see that the selected active order has 4 items, but only 2 are showing in the second gallery as two of the items have dropped off the screen as they've been filled.

     

    Thanks!

    Shawn

    Screenshot 2022-12-17 143303.png
  • Verified answer
    ShawnSchinkel Profile Picture
    57 on at

    Got it @Drrickryp! Not sure how elegant it is, but it solves all the problems I was trying to solve.

     

    I was able to AddColumns with CountRows involved based on OrderStatus filtering, and then compare the two. Only if they have the same count value are they included in the Complete filter.

     

    Here is the code for Gallery1.

     

    SortByColumns(
    Filter(
    AddColumns(
    If(
    IsBlank(ComboBox1.Selected),
    GroupBy(
    Clothing_Order_List,
    "OrderID",
    "GroupedOrders"
    ),
    GroupBy(
    Filter(
    Clothing_Order_List,
    Name.DisplayName = ComboBox1.Selected.DisplayName
    ),
    "OrderID",
    "GroupedOrders"
    )
    ),
    "Gallery1Active",
    Not(
    (CountRows(GroupedOrders) = CountRows(
    Filter(
    GroupedOrders,
    OrderStatus = "Filled"
    )
    ))
    ),
    "Gallery1All",
    CountRows(GroupedOrders),
    "Gallery1Complete",
    (CountRows(GroupedOrders) = CountRows(
    Filter(
    GroupedOrders,
    OrderStatus = "Filled"
    )
    ))
    ),
    If(
    Radio1.Selected.Value = "Complete",
    Gallery1Complete,
    Radio1.Selected.Value = "Active",
    Gallery1Active,
    Radio1.Selected.Value = "All",
    Gallery1All
    )
    ),
    "OrderID",
    Descending
    )

     

    The code for Gallery2 is simply 

     

    Gallery1.Selected.GroupedOrders

     

    Active showing all grouped items with mixed OrderStatus.

    Screen Shot 2022-12-18 at 1.30.39 PM.png

     

    And Complete showing only grouped items that have all their items marked as Filled.

    Screen Shot 2022-12-18 at 1.34.23 PM.png

     

    Thanks for looking into this for me!

     

    Shawn

     

     

     

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @ShawnSchinkel 

    Congrats!  Good Job!

     

    Smilegif.gif

     

  • AlejandraRamirezOrtega Profile Picture
    4 on at
    Hello Shawn, I know you solved this a while ago, but I'm running into a problem and after reading your solution I hope you can help me. I also have a SharePoint list where each record in the list is one item of an order. I'm trying to create a "Orders History" screen in power apps but I'm getting trouble understanding how I can group the records based on the OrderID. I'm new to this, but I have read that GroupBy() function is not delegable. My SharePoint list will have 10k+ values at some point. Do you have any ideas on how I can group them and show them in a gallery?

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

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 139

Last 30 days Overall leaderboard