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 / Using a Dropdown List ...
Power Apps
Unanswered

Using a Dropdown List to select a data source for a gallery

(1) ShareShare
ReportReport
Posted on by 133

Hi...I've been messing around with this for some time but I'm not quite there so hopefully you can help.
I have a SharePoint List of Report Names. I have separate SharePoint Lists, one for each report....they are identical in columns, names etc. so only the content in them is specific to the report.

I populate a dropdown with the data from the Report Names list and need to dynamically change the data source for the Gallery to the relevant SharePoint List.

e.g Report 1 selected = Report 1 SharePoint List as the data source for the gallery.

I've tried creating a variable onChange of the dropdown and I've tried referencing the Selected.Text, and Value, as Items for the gallery but no luck.

Any ideas?

Thanks 

Categories:
I have the same question (0)
  • Pro_User_365 Profile Picture
    546 on at

    Hi @psadd2 ,

      • In the Dropdown control's OnChange property, set the "SelectedReport" variable to the selected item's value. This captures the name of the selected report.

        Update Variable on Dropdown Selection:

       

     

     

    Set(SelectedReport, Dropdown1.Selected.Value)

     

     

    • Set Gallery Data Source:

      • Configure the Gallery control's Items property to use the selected report name to determine the data source. You can use a Switch function or If statements for this purpose.

      For example, if you have multiple SharePoint Lists named "Report 1," "Report 2," etc., you can set the Items property of the Gallery like this:

       

     

     

    Switch(
     SelectedReport,
     "Report 1", 'Report 1 SharePoint List',
     "Report 2", 'Report 2 SharePoint List',
     "Report 3", 'Report 3 SharePoint List',
     // Add more reports as needed
    )

     

     

    Replace 'Report 1 SharePoint List' with the actual SharePoint List names for your reports.

    • Gallery Display: Configure the Gallery control to display the data from the selected data source.

    Note: After receiving the answer, if you think it's helpful, please consider accepting it. 😊 Regards! Ali Shahzad

  • psadd2 Profile Picture
    133 on at

    Hi...thanks for the prompt response but using a Switch statement kind of negates the idea of the dropdown selecting a source dynamically. If I have to edit the Switch every time a new report is added to the list then it defeats the object.


    So my reference list, "Reports", simply has a list of the reports ( and the names are identical to the SharePoint list names) i.e. Report 1 refers to a list called Report 1...when a new report comes along I, or anyone else can add it to the list without needing to edit any code in the App.


    What I need to do is for my Gallery to take dropdown1.selected.value as an input for it's 'items'....but that doesn't work. I've also tried writing dropdown1.selected.value to a variable on the onChange of the dropdown and using that in the Gallery items....but nope.

     

    Thanks again

  • Pro_User_365 Profile Picture
    546 on at

    Hi @psadd2 , 

    1. Create a SharePoint List called "Reports" with a column for the report names.

    2. Populate the "Reports" list with the names of your reports (e.g., "Report 1," "Report 2").

    3. In the Gallery control's Items property, use a formula that dynamically selects the data source based on the dropdown selection. You can do this using the LookUp function.

      Here's an example formula for the Gallery's Items property:

      LookUp(Reports, Title = Dropdown1.Selected.Value).Title

      This formula searches the "Reports" list for the item whose "Title" column matches the selected value in Dropdown1 and returns that item's "Title."

      1. Now, the Gallery will dynamically change its data source based on the selected report in Dropdown1. If you add a new report to the "Reports" list, it will automatically be included without the need to edit the app's code.

     

  • psadd2 Profile Picture
    133 on at

    Hi....that's exactly what I had already done but it errors on the final ).Title as it says it's expecting a table value.
    I'm glad I'm thinking on the same lines as you though .😁 I think it may be because my list of report names has duplicates. Reason being each report may have more than one page to Report 1 may have Page one and Page two...which means the Report name appears twice.
    I have   Distinct('Commentary Report Reference List', Title) on my dropdown which works fine but can't get the gallery 'Items' to play ball.
    LookUp('Commentary Report Reference List', Title = Dropdown1.Selected.Value).Title
    The final ).Title isn't happy

     

    Thanks for your help on this one

  • Pro_User_365 Profile Picture
    546 on at

    Hi @psadd2 , 

    I understand the issue you're facing. To address this problem, you can use the First function to extract a single value from the result of the LookUp function. Here's how to modify your formula:

    First(LookUp('Commentary Report Reference List', Title = Dropdown1.Selected.Value)).Title

    This should resolve the error and allow you to dynamically change the data source for your Gallery based on the selected report in Dropdown1, even when there are duplicates in the report names.

    By using the First function, you ensure that only one record is selected from the result of the LookUp function, which should match your requirements.

    Note: If you find this solution helpful, please consider accepting it. 😊

  • psadd2 Profile Picture
    133 on at

    Oooooooo......that sounds so sensible...and I'd already tried that too but no luck. I even copied your string in....the whole thing red-lines. I have no idea why it won't work. Seems pretty straight forward to me.
    Does the Item for the gallery need the inverted commas around it to be seen as a table name? Is that the issue?

  • psadd2 Profile Picture
    133 on at

    Annoyingly I can pump out the right report name to a Label......just not as a name of a data source 🤬

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

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard