Yoan Tufel
Yoan Tufel

Reputation: 45

PowerApps default dropdown Items

The question i have is am trying to make an IF statement for a default item in a dropdwon menu.

In Items:

Table(
    {
        Text: "Renouvellement",
        Val: 1
    },
    {
        Text: "Nouveau Patient",
        Val: 2
    },
    {
        Text: "Non Renseigner",
        Val: 3
    }
)

in Default:

If(
    ThisItem.ORD_TYPE_SID2 = 1,
    "1",
    If(
        ThisItem.ORD_TYPE_SID2 = 2,
        "2",
        If(
            ThisItem.ORD_TYPE_SID2 = 3,
            "3"
        )
    )
)

What am trying to do is if the ORD_TYPE_SID is = to 1 or 3, then use the list index 1 or 3. How can i do that? but if i do show value the results is correct

Upvotes: 1

Views: 1542

Answers (1)

SeaDude
SeaDude

Reputation: 4375

Check out the PowerApps LookUp() Function. It brings back the first record (or field) in a Table that matches a condition.

Try:

  • Changing the Default property to:
LookUp(
    Table(
        {
            Text: "Renouvellement",
            Val: 1
        },
        {
            Text: "Nouveau Patient",
            Val: 2
        },
        {
            Text: "Non Renseigner",
            Val: 3
        }
    ), 
    Val = ORD_TYPE_SID2.Selected.Value,
    Text
)

Note:

  • The data type (numeric) of the Val field
    • This must match the data type in ORD_TYPE_SID2 dropdown
  • Also, probably best not to use a column called "Text" as this is a reserved word (the Text() Function).
    • It will still work but may be unreliable or lead to confusion down the road

Illustration:

enter image description here

Upvotes: 1

Related Questions