cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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 

2 REPLIES 2
Highlighted
Super User
Super User

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

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,

Lookup(Datasource1,ID=Gallery1.Selected.ID)

 

Highlighted
Advocate III
Advocate III

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

@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)]

Joel

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (4,401)