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 / Filter a Gallery based...
Power Apps
Answered

Filter a Gallery based on two SharePoint-Lists

(2) ShareShare
ReportReport
Posted on by 18

Hi,
I have two SharePoint lists, one contains a status_number (1,2,3,...) and a user. The list is called "User/Status"

Jensvth_0-1658483532925.png

The other one contains all my ticket information and also the status_number. The list is called "Ticket_information"

Now I want to filter a gallery based on the status_number. 

 

For example if the status_number in the "Ticket_information" list is 2 then the items in the gallery should only be visible for the users with the same status_number in the "Status/User" list.

 

Categories:
  • Verified answer
    poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Jensvth 

     

    Like this:

     

    SharePoint List Setup:

     

    List01:

     

    poweractivate_2-1658487551747.png

     

     

    Ticket_information:

     

    poweractivate_3-1658487577488.png

     

     

    Steps to build the Power App:

     

     

    aqq2.gif

     

     

     

    Add SharePoint Data sources List01 and Ticket_Information

     

    TextInput1 OnChange propety:

     

    UpdateContext({statNumByCurrentUser: LookUp(List01, ThisRecord.User = TextInput1.Text).Status_Number});
    UpdateContext({statNumByCurrentUserAsText: Text(statNumByCurrentUser)});

     

     

    Label1 Text property:

     

    "User (type in A, B or C)"

     

     

    Label2 Text property:

     

    "Status Number"

     

     

    Label2_1 Text Property

     

    If(!IsBlank(statNumByCurrentUserAsText),statNumByCurrentUserAsText,"~~NOT FOUND~~")

     

     

    Gallery1 Items property:

     

    Filter(Ticket_Information,Status_Number = statNumByCurrentUser)

     

     

     

    Working Example:

     

    aqq.gif

     

    Check if it helps @Jensvth 

     

     

     

  • Jensvth Profile Picture
    18 on at

    Thanks a lot @poweractivate ,
    this worked for me!

  • Jensvth Profile Picture
    18 on at

    Unfortunately I still have a problem. A user occurs more often, for example he has the Status_Number 1, 4, 6, but I only see tickets with the number 1 for him

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Jensvth 

     


    @Jensvth wrote:

    Unfortunately I still have a problem. A user occurs more often, for example he has the Status_Number 1, 4, 6, but I only see tickets with the number 1 for him


    Yes, it is possible to solve this problem as well, but the solution for that will be substantially more complex than the solution I gave at first.


    setup_01_List.png

     

     

     

    That means you have situation like this in List01, where for example a User "C" may have one or more records corresponding with a Status_Number, so in this example, you have a user "C" who has Status_Number of 3 and 4, as illustrated here.

     

    The solution is possible in Power Apps Canvas App.

    You can find the solution below.

     

    In addition to detailed step-by-step instructions below on how to build the app from scratch,

    I also have prepared a sample app this time (at bottom of this post) with simulated collections for the data source in case it helps you to have as a starting point. 

     

    Check below for steps to build from scratch, and sample app with instructions how to import the sample app:


    Steps

    • Create two blank screens Screen1 and Screen2
    • Screen1 OnVisible property, put this formula:

     

    ClearCollect(List01,{User:"A",Status_Number:1},{User:"B",Status_Number:2},{User:"C",Status_Number:3},{User:"C",Status_Number:4});
    ClearCollect(Ticket_Information,{Ticket_Name_:"1_1",Status_Number:1},{Ticket_Name_:"1_2",Status_Number:1},{Ticket_Name_:"2_1",Status_Number:2},{Ticket_Name_:"2_2",Status_Number:2},{Ticket_Name_:"3_1",Status_Number:3},{Ticket_Name_:"3_2",Status_Number:3},{Ticket_Name_:"4_1",Status_Number:4},{Ticket_Name_:"4_2",Status_Number:4});
    
    
    
    ClearCollect(tmp_Collection_Tickets_byCurrentStatusNumbers,{});
    ClearCollect(Collection_Tickets_byCurrentStatusNumbers,Defaults(Ticket_Information));
    
    
    Select(Button1);
    

     

     

    • You will place all of the Controls in the next steps, on Screen1, leaving Screen2 blank.
    • Place a Button Control Button1 and make it invisible (set Visible property to false)
    • Button1 OnSelect property, put this formula:

     

    Clear(tmp_Collection_Tickets_byCurrentStatusNumbers);
    Clear(Collection_Tickets_byCurrentStatusNumbers);
    
    Collect(
     tmp_Collection_Tickets_byCurrentStatusNumbers
     ,With(
     {
     outerFilter: 
     Filter(
     List01 As ThisUserRecord
     ,ThisUserRecord.User = TextInput1.Text
     )
     }
     ,ForAll(outerFilter As ThisUserRecordPreFilteredByUserSearch
     ,Filter(Ticket_Information,Status_Number = ThisUserRecordPreFilteredByUserSearch.Status_Number)
     )
    
     )
    );
    
    //Merge the multiple Collections
    ForAll(
     tmp_Collection_Tickets_byCurrentStatusNumbers
     ,Collect(Collection_Tickets_byCurrentStatusNumbers,ThisRecord.Value)
    );
    

     

     

    • Place Label Control Label1 
    • Label1 Text property: "User (type in A, B or C)"

     

    • Place Label Control Label2
    • Label2 Text property: "Status Number"

     

    • Place Label Control Label3
    • Label3 Text property: 

     

    With(
     {str:Concat(Distinct(Collection_Tickets_byCurrentStatusNumbers,Status_Number),ThisRecord.Result & ",")}
     ,If(Len(str)<1,"~~NOT FOUND~~",Left(str,Len(str)-1))
    )

     

     

    • Place TextInput Control TextInput1
    • TextInput1 Default property,: "C"
    • TextInput1 OnChange property:

     

    Select(Button1)

     

     

    • Place Gallery Control Gallery1. Use the default Vertical Gallery template.
    • Gallery1 Items property:

     

    Collection_Tickets_byCurrentStatusNumbers

     

     

    • Inside Gallery1, in the Label Control Subtitle1 use this for the Text property:

     

    ThisItem.Status_Number

     

     

    • Toggle between Screen2 and Screen1 once or twice to see results immediately.
    • You can preview the App and change the value of the Textbox to A, B, or C - and it should work correctly. If you use something like D, it should say "~~Not Found~~"

     

    Working Sample msapp

     

    have also attached a working sample msapp file app25.msapp if you would like to import a full, working example yourself for your convenience.

     

    sample_01.png

     

     

     

    To use the sample msapp attached, follow these steps:

     

    1) Download the msapp file attached to this post (it is at the bottom of this post), to Desktop or a folder of your choice, by clicking on it from this post.

    2) Create a new, blank Power App Canvas App

    3) Go to File -> Open -> Browse

    poweractivate_0-1658876951907.png

     

    4) Navigate to location of .msapp file from Step 1, select it, and press the "Open" button.

    5) The working example msapp file should load.

    6) Toggle between Screen2 and Screen1 once or twice to see results immediately.

    7) You can try the full working example and also check the working formulas and setup as well in the app.

    😎 You can even try to add your SharePoint Lists as data sources in the sample app after you import it, and use your SharePoint List names instead of the Collection names throughout the App and it might work.

     

    Check if it helps @Jensvth 

  • Jensvth Profile Picture
    18 on at

    Hi, 

    That worked perfectly, thank you very much for your help! You have greatly improved my app, 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 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 409 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 252 Most Valuable Professional

Last 30 days Overall leaderboard