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 / Populating a Dropdown ...
Power Apps
Answered

Populating a Dropdown Box with one of 2 Collections based on the value in another Dropdown box

(0) ShareShare
ReportReport
Posted on by 782

I have a Dropdown that is populated from a SharePoint List. I have 2 other Dropdowns that are populated with Collections based on which value is selected from the first Dropdown. My problem seems to be with loading the collection sorted and displaying Lastname, Firstname. My first dropdown is working fine and displays 2 values. My 2nd Dropdown seems to be struggling with the 2 field names in my collections. Here is the code:

 

Switch(dd_DataCardValue4_1.Selected.School,

    "Trad undergrad", Sort(AddColumns(ColAzureAdvisorsTug, "FullName", surname & ", " & givenName), surname),

    "GRTS (SEM)", Sort(AddColumns(ColAzureAdvisorsGRTS, "FullName", surname & ", " & givenName), surname)

)

Categories:
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Greg27 

    In general, using multiple datasources for a control in PowerApps is not a good design idea as this can lead to a host of issues at play time and in many cases is not allowed to even be entered.

    The only time that it is somewhat feasible is if the two tables are identical.

    So if your ColAzureAdvisorsTug and ColAzureAdvisorsGRTS are not identical, this will lead to issues.

    I would suggest dispensing with the use of the collection to start with, but otherwise making sure they have the same schema.

     

    Then I would look at duplication of formula.  You are performing the same type of operation twice.  My suggestion would be to simplify to the following:

    Sort(
     AddColumns(
     Switch(dd_DataCardValue4_1.Selected.School,
     "Trad undergrad", ColAzureAdvisorsTug, 
     "GRTS (SEM)", ColAzureAdvisorsGRTS
     ),
     "FullName", surname & ", " & givenName
     ), 
     surname
    )

     

     

    I hope this is helpful for you.

  • Greg27 Profile Picture
    782 on at

    @RandyHayes 

    I tried the statement you included and I still get the same errors. The 2 collections are the same, but I would rather do this the right way as opposed to making the wrong way work. If I drop the Collections, What is the best way to accomplish this?

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Greg27 

    Well let's see what is going on to begin with before dealing with the other aspect.  Although, if you state that the collections are identical, then there is not much concern over the formula.

     

    So what is it that you are seeing/not seeing??

  • Greg27 Profile Picture
    782 on at

    @RandyHayes 

    Here is a screenshot of the statement you gave me:

     

    Greg27_0-1646843316494.png

     

    If I hover over surname or givenName, I see the following:

     

    Greg27_2-1646843456703.png

     

    Without showing any data, Here are the column headers. This one is for ColAzureAdvisorsTug:

     

    Greg27_3-1646843575370.png

     

    Here is the one for ColAzureAdvisorsGRTS:

     

    Greg27_4-1646843637602.png

     

    Is there anything else that would help to see?

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Greg27 

    Formula and collection looks good.  So let's see what PowerApps is seeing...

    Place your cursor at the end of the name of your collection in the formula and type a "dot"/period and see what the column name suggestions are that comes up.

     

    Also, what is your Items property on the dd_DataCardValue4_1 control?

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Greg27 

    Oh...and I should add....

    Once you have typed the period after the collection name to see what it has, do the same thing at the end of the Switch function closing paren.  It should show the same column suggestions there as well.

  • Greg27 Profile Picture
    782 on at

    @RandyHayes 

    When I put a period after my first collection, it gave me the suggestion of 'value'. Here is the screenshot:

     

    Greg27_0-1646847919513.png

     

    Here is the screenshot of putting a period after the ')' which ends the Switch command:

     

    Greg27_1-1646848115029.png

     

    I hope I did this correctly. Let me know if you need any more information.

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Greg27 

    Not seeing the suggestions in the screenshot, but that's okay...you mention that all you see is Value, so there is something wrong.

    How are you populating that collection??  In other words, what is your Collect/ClearCollect statement?

     

  • Greg27 Profile Picture
    782 on at

    @RandyHayes 

     

    On the OnStart Property of the App, here is my code which loads the Collections:

     

    ClearCollect(ColAzureStaffulty, Office365Groups.ListGroupMembers("Azure Object ID")); ClearCollect(ColAzureAdvisorsTug, Office365Groups.ListGroupMembers("Azure Object ID")); ClearCollect(ColAzureAdvisorsGRTS, Office365Groups.ListGroupMembers("Azure Object ID")); Set(varStudentName,User().FullName);

     

    I replaced the actual Azure Object ID with the name "Azure Object ID".

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Greg27 

    Both of those actions return their table in the value property.

    So, change those to the following:

    ClearCollect(ColAzureStaffulty, Office365Groups.ListGroupMembers("Azure Object ID").value);
    ClearCollect(ColAzureAdvisorsTug, Office365Groups.ListGroupMembers("Azure Object ID").value);
    ClearCollect(ColAzureAdvisorsGRTS, Office365Groups.ListGroupMembers("Azure Object ID").value);
    Set(varStudentName,User().FullName);

     

    You really don't need a heavy-weight collection for those as your not going to be altering the results (i.e. add/remove/edit), so to be a little more performant in your app, you can change to variables.

    Ex.

    Set(varAzureStaffulty, Office365Groups.ListGroupMembers("Azure Object ID").value);
    Set(varAzureAdvisorsTug, Office365Groups.ListGroupMembers("Azure Object ID").value);
    Set(varAzureAdvisorsGRTS, Office365Groups.ListGroupMembers("Azure Object ID").value);
    Set(varStudentName,User().FullName);

     

    Also, what is the Items property of your dd_DataCardValue4_1 control?

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 234 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard