cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
the365bit
Resolver I
Resolver I

Select DropDown Item on Change of AnotherDropDown

Hi Experts,

 

I'm trying to select a value in a Project Team Member dropdown whenever I change the value in a Project dropwdown.

 

I already have both dropdowns populated and what I wanted to achieve would look something like this in a pseudo code manner

 

ProjectTeamMember.OnChange => fx [Project.SelectedItem = First(ProjectTeamMember)]

 

Basically I have a list of projects and I want to select the first project team member everytime I change the project.

 

the365bit_0-1595521416383.png

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User III
Super User III

@the365bit 
Yes, that's possible.

 

To change the Project Team Member put this code in the Default property of its dropdown.  I assume project team member is also a ComboBox not a dropdown.

 

LookUp(your_datasource_name, Project=ComboBox_Project.Selected.Project, 'Project Team Member')


Then put this code in the OnChange property of the Project ComboBox to reset its partner to the Default value.

Reset(ComboBox_ProjectTeamMember)


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

 

View solution in original post

5 REPLIES 5
mdevaney
Super User III
Super User III

@the365bit 
Yes, that's possible.

 

To change the Project Team Member put this code in the Default property of its dropdown.  I assume project team member is also a ComboBox not a dropdown.

 

LookUp(your_datasource_name, Project=ComboBox_Project.Selected.Project, 'Project Team Member')


Then put this code in the OnChange property of the Project ComboBox to reset its partner to the Default value.

Reset(ComboBox_ProjectTeamMember)


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

 

View solution in original post

Hi @mdevaney ,

 

Thank you for the reply.

 

But in this case if I use Lookup I'll be effectively performing another query in the database right? Because at the moment I already have a Filter(Source, Condition) in the Items property of my Project Team Member ComboBox.

TiagoFreire
Continued Contributor
Continued Contributor

Yes, it requires another query, but a datasource can be a collection as well. 

maybe the project db is too large to be loaded in a Collection, but accessory data like the list of users might be small enough to be Collect()ed, and you can lookup against that to save a server roundtrip. 

@the365bit 
Yes, you will be doing another 'query' in the database but I don't see why that matters.   There's not any performance or API usage issues here. 

 

Can you please state your concerns?  I don't know what they are?

Also, did you try the code?  No sense in talking about concerns if the code doesn't work.  Please implement it first.

 

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

Hi @TiagoFreire , @mdevaney 

 

Thank you for he answers.

 

@mdevaney I did try the code but it didn't work as it is but your suggestion on using the Default property and Reset(Combo) helped me try other functions using these properties and I actually ended up with the following solution that it's now working:

 

ProjectComboBox.Items= fx [ [@ProjectDataSource] ]

ProjectTeamMemberComboBox.DefaultSelectedItems = Filter('Project Team Members', 'User'.'Email' = User().Email && 'Project'.'Id'= ProjectComboBox.Selected.Id)

ProjectTeamMemberComboBox.Items = ""

ProjectComboBox.OnChange(Reset(ProjectTeamMemberComboBox))

 

Before I was doing this, the item that I wanted to auto select was there but wasn't default selected though.

 

ProjectComboBox.Items= fx [ [@ProjectDataSource] ]

ProjectTeamMemberComboBox.DefaultSelectedItems = ""

ProjectTeamMemberComboBox.Items = Filter('Project Team Members', 'User'.'Email' = User().Email && 'Project'.'Id'= ProjectComboBox.Selected.Id)

 

I mentioned the performance concerns as I believe no matter which platform we're working on if you can meet the requirement with one query why would you want to do more then one.

 

Thank you again for the time on that guys.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (3,256)