3

I would like to select a dropdown value and then show some other values extracted from the excel datatable on a label. For instance, if I select "Jonathan Soh" in the dropdown list, the text label will show "a". Else if I select "Peter" in the dropdown list, the text label will show "b" and etc.

Below is the canvas-app formula I have tried but it can only select the dropdown list value and show dropdown list value on the text label. Please see the image for better understanding.

If(
    InspectorDropdown.Selected.Value = "Jonathan Soh",
    "Jonathan Soh",
    InspectorDropdown.Selected.'name ')
carlosfigueira
  • 85,035
  • 14
  • 131
  • 171
J_Y
  • 143
  • 4
  • 16

1 Answers1

1

You're in the right track with the If function; in your case, you can use an expression like this one for the label:

If(
    InspectorDropdown.Selected.Value = "Jonathan Soh",
    "a",
    InspectorDropdown.Selected.Value = "Peter",
    "b",
    InspectorDropdown.Selected.'name ') // this last value will be used if nothing matched before

In this specific case, if you're always comparing with the same value, you can also use the Switch function, which will make the expression a little easier to read:

Switch(
    InspectorDropdown.Selected.Value,
    "Jonathan Son", "a",
    "Peter", "b",
    "James", "c",
    InspectorDropdown.Selected.'name ') // this last value will be used if nothing matched before
carlosfigueira
  • 85,035
  • 14
  • 131
  • 171