Lookup function in Powerapps

101 Views Asked by At

Please help me to get the correct lookup value formula in PowerApps, my requirements are as follows.

I want to search for a field in an Excel matrix according to the activity selected in drop-down fields. In these dropdowns you must select the value or name of the row and also the column and the result must be the matching field in the row and column matrix. I have the problem taking the text value from the dropdown in the column

I have this:

LookUp(Matrix; Row=List_Afectacion.SelectedText.Value).'TEXT_IN_Column'

It works correctly but I need to choose the text from the column of a dropdown or another type of entry

I want this:

LookUp(Matrix; Row=List_Row.SelectedText.Value).**List_column.SelectedText.Value**

Other wide I try but don't work:

LookUp(Matrix; Row=List_Row.SelectedText.Value;List_Colum.SelectedText.Value)

This returns me the same column name value (List_Colum.SelectedText.Value), not the field in which it is intercepted

Matrix Example

If I select the value of List_Row_2 from the dropdown List_Row and select the value of List_Column_3 from the dropdown List_Colum, it should return the value "8"

1

There are 1 best solutions below

0
Ganesh Sanap - MVP On

Unfortunately, referencing column names dynamically (i.e. via variables or string values selected from drop down) is not supported in Power Apps.

Check related threads:

  1. Dynamic Collect column name
  2. Use variable in collection instead of column name

There are some similar ideas already posted on ideas forum. You can consider voting them at:

  1. Patch - Reference a column name via a variable
  2. Reference an Object by name string

You can try this workaround using Switch once:

With(
    {varSelectedRow: LookUp(Matrix, Row = List_Row.Selected.Value)},
    Switch(
        List_Column.Selected.Value,
        "List_Column_1",
        varSelectedRow.List_Column_1,
        "List_Column_2",
        varSelectedRow.List_Column_2,
        "List_Column_3",
        varSelectedRow.List_Column_3,
        "List_Column_4",
        varSelectedRow.List_Column_4,
        "List_Column_5",
        varSelectedRow.List_Column_5,
        "List_Column_6",
        varSelectedRow.List_Column_6
    )
)

Output:

enter image description here