How to Set Dropdown Value on Button Click in Power Apps?

This Power Apps tutorial explains how to set a dropdown value on a button click in Power Apps. I will show you, how to change the Power Apps dropdown value by clicking on a button click.

Additionally, we will discuss how to set Power Apps dropdown values based on variable.

Set Dropdown Value on Button Click in Power Apps

I will show you how to set the dropdown value on a button click in Power Apps.

Example 1:

I have created a Power Apps Canvas app and then added a Slider Control, Button Control, and a Dropdown control. The Power Apps dropdown control contains the “Project Status” values that I have added manually.

Next, Whenever the user adjusts the slider and clicks on a button control. The dropdown items will be updated based on the slider control value.

Set the Power Apps dropdown value on a button click

Follow the below steps to achieve this:

Step 1:  [Insert a Slider control]

  • On the Power Apps screen, insert a Slider control.
How to set Power Apps dropdown value on button click

Step 2: [Insert a Dropdown control and add the items manually]

  • Insert a Dropdown control -> Set its Items property to:
["Completed" , "In progress", "Not Started"]
Set dropdown value on a button click in Power Apps

Step 3: [Insert a button control and create a variable to set a dropdown value]

  • Insert a Button control -> Set its OnSelect property to:
If(
    sld_ProjectCompletion.Value = 100,
    UpdateContext({varSetDrp: {Value: "Completed"}});
    Reset(drp_ProjectStatus),
    sld_ProjectCompletion.Value < 2,
    UpdateContext({varSetDrp: {Value: "Not Started"}});
    Reset(drp_ProjectStatus),
    sld_ProjectCompletion.Value < 100,
    UpdateContext({varSetDrp: {Value: "In progress"}});
    Reset(drp_ProjectStatus)
)

Where,

  1. sld_ProjectCompletion = Slider Control name
  2. varSetDrp = Provide the variable name
  3. Completed, Not Started, In progress = Dropdown values
  4. drp_ProjectStatus = Dropdown control name
Power Apps set dropdown value based on a button click

Step 4: [On the dropdown control, assign a variable to set a dropdown value]

  • Select a Dropdown control -> Set its Default property to:
varSetDrp.Value

Where,

  1. varSetDrp = Assign the variable name here
Update the Power Apps dropdown value on button click
  • SavePublish, and Preview the app, when a user adjusts the slider control and clicks on a button control. The dropdown will automatically select an item based on the slider value.
How to update Power Apps dropdown value on a button click

This is how to set a dropdown value on a button a click in Power Apps.

Example 2:

I have a SharePoint Online list [Recruitment Tracker], that has different columns like:

Column NameData Type
Candidate NameTitle
PositionChoice [“Project manager”,” User Researcher”, “Designer”, “Account Manager]
ProgressChoice [“Active”, “On hold”, “Offer sent”, “New Application”, “Top pick”]
Application DateDate and time
Interview DateDate and time
Power Apps set the dropdown value on a button click

I have created a Power Apps Canvas app and then added a Dropdown control and a Button control. The dropdown control contains all the values from the SharePoint list choice column. When a user clicks the button control [Change Progress To Active], the dropdown value should be updated to Active.

Power Apps set dropdown value on a button click

Let’s see how to achieve this:

  • On the Power Apps screen, insert a Button control and set its OnSelect property to:
Set(
    varDropDownDefault,
    "Active"
);

Where,

  1. varDropDownDefault = Variable name
  2. Active = SharePoint List Choice column value
Set the dropdown value on a button click in Power Apps
  • Above button control, insert a Dropdown control -> Set all the below properties of this dropdown as:
Items = Distinct(
    'Recruitment Tracker',
    Progress.Value
)

Default = varDropDownDefault

OnChange = Set(
    varDropDownDefault,
    Self.Selected.Value
)
How to change the dropdown value on a button click in Power Apps
  • Save, Publish, and Preview the app. Click on the button control, then by default dropdown item will be selected as “Active”.
Set Power Apps dropdown value based on button click

This is how we can update a dropdown value on a button click in Power Apps.

How to Set Power Apps Dropdown Values Based on Variable

In this section, I will explain how to set a Power Apps dropdown value based on a variable

Example 1:

  1. In Power Apps, there is a Slider Control and a Dropdown control.
  2. When the user adjusts the slider, based on it, the dropdown items will be selected.
Power Apps set dropdown value based on variable

To achieve this, follow the below steps:

  • On the Power Apps screen, insert a Slider Control -> Set its OnChange property to:
If(
    Self.Value = 100,
    UpdateContext({varSetDrp: {Value: "Completed"}});
    Reset(drp_ProjectStatus),
    Self.Value < 2,
    UpdateContext({varSetDrp: {Value: "Not Started"}});
    Reset(drp_ProjectStatus),
    Self.Value < 100,
    UpdateContext({varSetDrp: {Value: "In progress"}});
    Reset(drp_ProjectStatus)
)

Where,

  1. varSetDrp = Variable name
  2. Completed = Dropdown value
  3. drp_ProjectStatus = Dropdown control name
How to set Power Apps dropdown value based on a variable
  • Insert a Dropdown control -> Set its Items property to:
varSetDrp.Value
Set dropdown value based on variable in Power Apps
  • Save, Publish, and Preview the app. When the user moves the slider, based on it, the dropdown value will be selected automatically.
Power Apps set dropdown value based on the variable

This is how we can set a Power Apps dropdown value based on a variable.

Example 2: [Using SharePoint List]

I have a SharePoint list [Employee Details], which has various columns like:

Column NameData Type
Employee IDTitle
Employee NameLookup
Employee Department Lookup
GenderChoice [Male, Female]
Joined DateDate and time
Setting value of a dropdown based on variable in Power Apps
  1. In Power Apps, there is a Text input control, a Search icon, and a Dropdown control.
  2. The dropdown control has the values from a department column [IT, Marketing, Finance, HR].
  3. Whenever the user provides their Employee ID in the text input control and clicks on the search icon, by default, the dropdown item will be selected for their department.
Power Apps set value of dropdown based on variable

Let’s see how to achieve this:

  • On the Power Apps screen, insert a Text input control -> Set its Hint text property to:
"Provide Your Employee ID"
Power Apps set dropdown value based on a variable
  • Insert a Search icon -> Set its OnSelect property to:
Set(
    varEmpDepartment,
    LookUp(
        'Employee Details',
        Title = txt_EmployeeID.Text
    ).Department.Value
)

Where,

  1. varEmpDepartment = Variable Name
  2. Employee Details = SharePoint list name
  3. Title = SharePoint list column which has all the Employee ID
  4. txtEmployeeID = Text input control name
  5. Department = SharePoint list column name
How to set dropdown value based on variable in Power Apps
  • Insert a Dropdown control -> Set the below-mentioned dropdown properties to
Items = Distinct(
    'Employee Details',
    Department.Value
)

Default = varEmpDepartment 
Setting value of a Power Apps dropdown based on variable
  • Save, Publish, and Preview the app. When you provide the employee ID and click on a search icon, the dropdown value will be selected based on the provided employee ID.
Set Power Apps dropdown value based on variable

Conclusion

This Microsoft Power Apps tutorial taught us all about “How to set the dropdown value on a button click in Power Apps.”

You may like: