Reputation: 21
Ok, this seems quite basic, but I can't figure out.
I have a record myRecord = {key1: "value1", key2: "value2"}
I also have myCombo with the options ["key1", "key2"]
Then I want to display the value myRecord[myCombo.Selected.Value]
Any ideas how to do this in Powerapps?
Upvotes: 0
Views: 16
Reputation: 87218
If the options are known, then you can use a Switch function similar to the code below:
Switch(
myCombo.Selected.Value,
"key1", myRecord.key1,
"key2", myRecord.key2
)
If the options are not known, then you cannot do this for "regular" records. If you are working with untyped objects, then you can access them dynamically. For example, if your record comes from the following expression:
Set(
myUntypedRecord,
ParseJSON("{""key1"": ""value1"", ""key2"": ""value2""}"))
Then you can access the columns from the record using the Column function:
Column(myUntypedRecord, myCombo.Selected.Value)
The result of that function is itself untyped (we don't know beforehand what it may contain), so you may need to use one of the functions to convert it to a typed value.
Upvotes: 0