0

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?

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.