Showing results for 
Search instead for 
Did you mean: 
Not applicable

Is it possible to store a SharePoint list name as a variable?

I would like to be able to dynamically change the SharePoint list being used as the data source for a gallery by looking up a unique ID in a SharePoint list that stores IDs and the corresponding list name. There could be hundreds of unique ID-list pairings used, so hard-coding is not an option. Is this possible? I am willing to take any kind of solution (variable, lookup, collection, etc.).

Super User
Super User


Hello again!  I will try my best to give you some ideas of what are possible here.


Attempting to use a gallery for more than one datasource is problematic because the Items property of a gallery can only have one possible SharePoint list as datasource.  Using IF a statements to determine which gallery should be shown will not solve this problem.  The next idea is to create a new Collection, use it as the gallery's datasource and fill/clear it with the information from different SharePoint lists. This could work but there are two major limitations: both SharePoint lists must have exactly the same columns feeding into the collection and the maximum number of records is 500.  Not to mention it will increase the complexity of building your app.


I think the simplest idea here is to try using multiple galleries: one gallery for each SharePoint list.  Place all of the galleries in the same position and use the Visible property to show or hide them.  Only one gallery should be showing at a time.  You could accomplish this by creating a variable called showGallery and setting it to a unique name for each gallery.




To ensure the gallery for MyList1 is showing when you need it put this code into the Visible property of the gallery.



Repeat this idea for each Gallery/SharePoint list and then build some method to toggle between them.


Hopefully my idea is clearly explained and makes sense.  Please let me know what you think.


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."

Community Support
Community Support

Hi @Anonymous ,


Currently, PowerApps doesn't support dynamic data source. You can submit an idea or vote for this existing idea: Dynamic Data Source .

What we can do in PowerApps is to hardcode the data source in condition statement, and display the fields with the same name and type of all data sources in gallery.


However, Office365Master came up with a whole new idea, get the content stored in SharePoint online by Power Automate and Graph v2 API, checking his Blog and YouTube might open up some new ideas for you.


Best regards,

Helpful resources

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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