Search code examples
powerappspowerapps-formula

How to onSelect dropdown1 item to show different dropdown2 item in PowerApps?


Below is the canvas-app formula that I have tried but it does not work:

If(
    DisplayInspectorDropdown.Selected.Value = "Jonathan Soh",
    true,
    DisplayBuildingDropDown.Selected.Value = "EC - Empire Complex")

Please do take a look to improve the canvas-app formula!! Thanks

I have encountered this error: Please see the image here


Solution

  • In PowerApps you cannot directly "assign" a value to a control; a control can reference other controls or variables, and they react to changes to those.

    In the first dropdown, if the names in the Inspector table are already unique, then you don't need to use the Distinct function, you can set the Items property directly to Inspector. That will help when making the selection in the second dropdown.

    On the second dropdown (DisplayBuildingDropDown) control, you need to update the Items expression so that it would filter the buildings based on the selection of the first one, something along the lines of

    Filter(
        Building,
        inspectorID = DisplayInspectorDropDown.Selected.inspectorID)
    

    Where Building is the name of the data source that contains the buildings that you want to display, and inspectorID is the name of the column within that data source that corresponds to the values in the first dropdown.