Hey everyone,
I am new to learning PowerApps, so forgive me if my question is silly, but I can't seem to figure it out.
I have a gallery with the items property set to a collection named colTest.
This collection contains two columns: Name and Number
Then I added a DropDown with the items property set to colTest.
When I reset this DropDown, I want it to select the second record of my collection.
Therefore, I set the default property of this DropDown to be: LookUp(colTest; Number = "Number 2").Name
This doesn't work. When I reset this DropDown, it just selects the first record again.
Solved! Go to Solution.
So the thing about selecting a Dropdown default is that you only have to match string to string - AND it must be on the string being displayed. You cannot match on a column in the Items records that is not displayed. Unlike a combobox where you have to match record to record.
So, in your case, the varRecord already has what you need in it. You can set your Default property to : varRecord.Name
But, given that you have non-unique names, this will not match what you want in the Dropdown. The reason is, the Dropdown will only match the first record that contains the value you are specifying to match. In other words, the fact that you want record #2 in your example is not relevant to the dropdown because you are ultimately deriving the Name to match...which it will - the first one.
My suggestion would be to augment the displayed value in the dropdown to be something that is unique - if that is at all possible. i.e. Name 1 (number 1) and Name 1 (number 2)
Then your Default can be : LookUp(colTest; Number = varRecord.Number).Name & " (number " & varRecord.Number & ")"
This would match as you want.
The only other suggestion is to change to a combobox and then there you will be matching record to record in the DefaultSelectedItems property. In that case the match is on the exact record and not the string text.
Just type "Name 1" in the default
Hi , Default:"Name 2"
First important question is - are you actually working with a Dropdown control or a Combobox. These are two completely different things.
If it is a Dropdown, then is your intention to replace the Gallery with a Dropdown, or is it that you want the dropdown to display as a default the selection from the Gallery?
First of all, thank you for taking the time to answer my question!
I am working with a DropDown, not a ComboBox.
When I select the first record in my Gallery, I want my DropDown to look like this:
When I select the second record in my Gallery, I want my DropDown to look like this:
Here is how I tried to accomplish this:
To know which record I selected, I set the OnSelect property of the icon in my Gallery on: Set(varRecord; ThisItem)
Then I set the Default property of my DropDown to be: LookUp(colTest; Number = varRecord.Number).Name
I used Number since the values in the Name column aren't unique.
This LookUp doesn't seem to work since my DropDown shows me the first record, instead of the second.
If I were to set the Default property of my DropDown to varRecord.Number, it works as expected.
However, I want to see the Name value in my DropDown instead of the Number value.
So the thing about selecting a Dropdown default is that you only have to match string to string - AND it must be on the string being displayed. You cannot match on a column in the Items records that is not displayed. Unlike a combobox where you have to match record to record.
So, in your case, the varRecord already has what you need in it. You can set your Default property to : varRecord.Name
But, given that you have non-unique names, this will not match what you want in the Dropdown. The reason is, the Dropdown will only match the first record that contains the value you are specifying to match. In other words, the fact that you want record #2 in your example is not relevant to the dropdown because you are ultimately deriving the Name to match...which it will - the first one.
My suggestion would be to augment the displayed value in the dropdown to be something that is unique - if that is at all possible. i.e. Name 1 (number 1) and Name 1 (number 2)
Then your Default can be : LookUp(colTest; Number = varRecord.Number).Name & " (number " & varRecord.Number & ")"
This would match as you want.
The only other suggestion is to change to a combobox and then there you will be matching record to record in the DefaultSelectedItems property. In that case the match is on the exact record and not the string text.
Thank you so much!
I replaced the DropDown with a ComboBox and just set the SelectMultiple property to false.
Then I set the DefaultSelectedItems property to LookUp(colTest; Number = varRecord.Number).
Works like a charm!
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
199 | |
71 | |
51 | |
42 | |
30 |
User | Count |
---|---|
268 | |
119 | |
98 | |
92 | |
82 |