0
votes

I need to filter a dropdown list from the results of another dropdown list above it. I'm filtering personnel based on their respective agency, so when the user selects their Agency from the first dropdown list, the second dropdown list is only populated with Personnel from that Agency.

Agency and Personnel are two separate entities (tables) in the common data service (CDS).

So far I can get the list of Agencies from the CDS with

Filter(Agency, AgencyType = 9)

where [9] = the type of agency I'm filtering for.

I just can't get the list of people assigned to that agency to populate. I have tried:

ITEM: Filter(Personnel, ddAgency.Selected.Value in Personnel.AgencyID) where ddAgency is the name of the referenced dropdown.

I am getting a single table error from PowerApps, so I guess it's my syntax. I'm trying to filter data and draw results based on values in 2 entities (tables).

Any suggestions?

1

1 Answers

0
votes

You probably want something along the lines of

ddPersonnel.Items: Filter(Personnel, AgencyID = ddAgency.Selected.Value)

The expression used to filter the data source already assumes that you are in the context of the data source being filtered, so you don't need to specify Personnel.AgencyID - AgencyID is enough.

The expression on the right of the equality sign (ddAgency.Selected.Value) may need to be updated, if the column that has the agency id is not called Value. For example, if it's called Id, the expression would be the one below.

ddPersonnel.Items: Filter(Personnel, AgencyID = ddAgency.Selected.Id)

You can read this as "Filter the data source Personnel where the value of the AgencyID field is the same as the value of the Id of the Agency element selected in the dropdown ddAgency.