Showing results for 
Search instead for 
Did you mean: 
New Member

PowerApps choose data source (Tables) in gallery based on button click

Hello everyone,


I have multiple tables in my PowerApps with same fields, I just want to choose the table whose button has been clicked on the last page. I am able to navigate to the next page with the variable to check which data source should we choose, I have tried to use Switch statement as follows in the Items of the gallery:


Switch(variablefrompreviousscreen,"Match String 1",DataSource1,"Match String 2",DataSource2,DataSource3) but this gives me some errors and doesn't seem to be the solution


Please let me know how i can do this. If not, Please specify alternate approaches: I am thinking about have a single table and using the filter or creating my own collection in PowerApps.


Your help would help me improve based on this 

Super User
Super User

Hi @fbatra 

I use Set(ds, Datasource1) to create an alias for various datasources or for different filters and use ds as the Items property of my Gallery. However, the datasource of the gallery must match exactly the datasource of the Edit or View form that you navigate to and the problem is that you cannot use a variable as the datasource of a form.  If you use a different form for each datasource, you will need set the Item property using a Lookup() to the datasource and a unique field.  For example,



Advocate III
Advocate III

@fbatra  I don't know if you can manipulate the "ITEMS" setting with Switch, but you may be able to achieve what you want by playing with the visibility property using your defined variable variable.


  1. Place 3 Galleries on the screen you want.
  2. Assign Datasource in the items field of your gallery to the 3 datasources you want to switch between
  3. Modify Visible property using the variable you have defined from the previous page, [EX: If(variablefrompreviousscreen="Match String 1",true,false)]


Helpful resources

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,786)