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 / Click button and chang...
Power Apps
Unanswered

Click button and change Datasource table on gallery screen.

(0) ShareShare
ReportReport
Posted on by 96

If i have three button and three sharepoint list. And i have one gallery screen.

If i click one button to navigate to gallery screen. My gallery screen code is below:

SortByColumns(Filter( 'PF502X Sample Request', 'Created By'.Email = User().Email , TextSearchBox1_6.Text in 'Part No.' || TextSearchBox1_6.Text in Customer ), "Created", If(SortDescending1, Ascending, Descending))

How to setup button onselect code and gallery screen code can achieve that change button to navigate gallery screen and the gallery screen datasource table will change by the button represent.

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,991 Moderator on at

    @Dennis_Qiang 
    Put this code in the OnSelect property of your 3 buttons.

    Set(varDatasource, "Table1");
    Navigate(GalleryScreen);
    Set(varDatasource, "Table2");
    Navigate(GalleryScreen);
    Set(varDatasource, "Table3");
    Navigate(GalleryScreen);

     

    Then put this code in the Items property of the Gallery.

    If(
     varDatasource="Table1",
     SortByColumns(Filter('Your Table Name 1', 'Created By'.Email = User().Email , TextSearchBox1_6.Text in 'Part No.' || TextSearchBox1_6.Text in Customer ), "Created", If(SortDescending1, Ascending, Descending)),
     varDatasource="Table2",
     SortByColumns(Filter('Your Table Name 2', 'Created By'.Email = User().Email , TextSearchBox1_6.Text in 'Part No.' || TextSearchBox1_6.Text in Customer ), "Created", If(SortDescending1, Ascending, Descending)),
     varDatasource="Table3",
     SortByColumns(Filter('Your Table Name 3', 'Created By'.Email = User().Email , TextSearchBox1_6.Text in 'Part No.' || TextSearchBox1_6.Text in Customer ), "Created", If(SortDescending1, Ascending, Descending))
    )

     

    Please note: your tables must all have the exactly same number of columns and column names 🙂

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

     

  • Dennis_Qiang Profile Picture
    96 on at

    Hi @mdevaney 

     

    Can i use the below type?

    For three button,

     

    Set(varDatasource, "Table1");
    Navigate(GalleryScreen);
    
    Set(varDatasource, "Table2");
    Navigate(GalleryScreen);
    
    Set(varDatasource, "Table3");
    Navigate(GalleryScreen);

     

     

     For the Gallery,

     

    SortByColumns(Filter('varDatasource', 'Created By'.Email = User().Email , TextSearchBox1_6.Text in 'Part No.' || TextSearchBox1_6.Text in Customer ), "Created", If(SortDescending1, Ascending, Descending))

     

    Is it possible to store the table in a variable?

     

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 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard