Can I populate a dropdown's items with value-text pairs, rather than just texts? And then retrieve a numeric Value rather than the displayed text? in other words, emulate
<Select><Option value=1>Item 1</Option><Option Value=2>Item 2</Option><Option Value=3>Item 3</Option></Select>
Solved! Go to Solution.
Yes, you can do that. You can set a list (table) or objects as the items for a Dropdown control. The objects can have multiple properties, and you can select which property to display, and can access the other properties.
For example, if you set the value of the Items property as the following:
Table({ Text: "Item 1", Val: 1 }, { Text: "Item 2", Val: 2 }, { Text: "Item 3", Val: 3 })
You can select the value to be displayed by selecting the View / Advanced option in the ribbon.
And in another control, you can select the "Val" property of the Selected item in your dropdown. For example, you can set the Text property of a Textbox to the following expression:
"Selected value: " & Dropdown1.Selected.Val
And if you select the option named "Item 2", the text box will display "Selected value: 2".
Yes, you can do that. You can set a list (table) or objects as the items for a Dropdown control. The objects can have multiple properties, and you can select which property to display, and can access the other properties.
For example, if you set the value of the Items property as the following:
Table({ Text: "Item 1", Val: 1 }, { Text: "Item 2", Val: 2 }, { Text: "Item 3", Val: 3 })
You can select the value to be displayed by selecting the View / Advanced option in the ribbon.
And in another control, you can select the "Val" property of the Selected item in your dropdown. For example, you can set the Text property of a Textbox to the following expression:
"Selected value: " & Dropdown1.Selected.Val
And if you select the option named "Item 2", the text box will display "Selected value: 2".
Is something like this also possible for a datacard. Suppose I have a Sharepoint list (1) that has a lookup field Country. Another Sharepoint list (2) contains the countries. It has 2 fields, country code and country description. In PowerApps I want to maintain list 1 and I would like to show the user the country description in the dropdown, but store the country code. Thanks in advance.
Thanks @CarlosFigueira for this. I can confirm that the dropdown displays the "text", and after selecting an item, I can save and the "val" that is selected gets saved in the database.
However, when I go back to edit the same entry, I notice that the default item in the dropdown menu does not reflect what "val" is set to in the database. As a matter of fact, it remains blank. How do we get the dropdown menu to have what "val" is stored in the database? Thank you.
I believe that if you find a similar item from the table in the Default property of the dropdown, you should be able to get your scenario to work.
If your dropdown is inside a data card (which has a Default property with the value that you want selected), this formula should work (edited to add missing property reference):
Dropdown1.Default: Lookup( Table({ Text: "Item 1", Val: 1 }, { Text: "Item 2", Val: 2 }, { Text: "Item 3", Val: 3 }), Val = Parent.Default).Text
@CarlosFigueira thank you, but when I click on the DataCardValue (the dropdown box), where the Items attribute is the "Table()" list, I edited the "Default" attribute to what you suggested, but I get the error:
"This property expects Text values, but this rule produces incompatible Record values."
Do I need to somehow specify to only return the "Text" field? Thanks.
Yes, I was missing the .Text reference in the default declaration. It should be as follows:
Dropdown1.Default: Lookup( Table({ Text: "Item 1", Val: 1 }, { Text: "Item 2", Val: 2 }, { Text: "Item 3", Val: 3 }), Val = Parent.Default).Text
Hi RonAtSogeti,
Did you ever find how to do this?
I'm faced with the exact situation.
Thanks in advance!
Hey guys,
I solve my issue at least. Here is what i did:
Problem: Need to display two fields (GenderID and GenderDesc) on the same Dropdown list.
This comes from a Sharepoint list.
When I select the item, i want to save only the GenderID.
Solution:
In Sharepoint I changed the field "GenderID" from the list called "UCA_Gender", from length 4 to 30.
In Sharepoint I changed the field "CI_Gender" from the list called "UCA_ClientsInfo", from length 4 to 30.
DataCardGender_1.Update = Dropdown7_1.Selected.GenderID
DataCardGender_1.Dropdown7_1.Items = AddColumns(UCA_Gender, "GenderIDDesc", Concatenate(GenderID, "-", GenderDesc))
DataCardGender_1.Dropdown7_1.OnSelect = Dropdown7_1.Selected.GenderID
Works like a charm !!!
If you guys need a full explanation (screeshots and such) let me know and i'll be glad to provide it in this post.
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
196 | |
175 | |
62 | |
34 | |
32 |
User | Count |
---|---|
342 | |
271 | |
112 | |
75 | |
59 |