Hi Members,
I have a requirement in Power Apps where I want to set a dropdown value based on a variable.
Scenario:
I have two SharePoint lists Company details and Employee Details. The company details list includes all departments. The employee details list will save all details of the employees with their department.
In Power Apps, there are Text input control, a search icon, and a Dropdown control.
If the user enters the Employee ID in the text input control and clicks on the search icon.
The employee ID will be fetched from the Employee details SharePoint list and displayed in their department in the dropdown control.
In the Search icon button, I have set a variable as
Set(varEmp,TextInput1)

Then in the Power Apps dropdown control, Items property, I have put the below code:
)
If(
IsBlank(varEmp),
Distinct(
'Company Details',
Name
),
(LookUp(
'Employee Details',
TextInput1 = varEmp
).Department)
)

But, I was facing an issue like, the dropdown control value was fetching only SharePoint list 1st value as IT.
For example, If I give the Employee ID = TS763 and click on the search icon the dropdown value will be fetched as IT only.

But the Employee ID TS763, is belongs to the marketing department.

I need the dropdown item should be selected based on the Employee ID.
Can anyone please suggest how I can resolve this? Thanks in advance!