Skip to main content
Community site session details

Community site session details

Session Id : bkZWcFq0q1H0rfbO8XooU1
Power Apps - Building Power Apps
Answered

Set Variable from drop down

Like (0) ShareShare
ReportReport
Posted on 23 May 2024 01:41:24 by 79

Hi All,

 

Trying to set a variable when a drop-down value is equal to no I have the below on the drop downs "OnSelect" the drop down itself is also a variable "var_dropdown"

 

If(dropdown.SelectedText = "No"),Set(var_output , "TEXT")

 

Any suggestions would be greatly appreciated

  • Mclean2023 Profile Picture
    79 on 27 May 2024 at 13:50:36
    Re: Set Variable from drop down

    Thank you so much, that worked perfectly

  • Verified answer
    MuhammadAizaz Profile Picture
    53 on 27 May 2024 at 07:23:48
    Re: Set Variable from drop down

    Hello @Mclean2023 ,

    Here is the tested code for the onChange property of Dropdown box.

    Please let me know if it works.

     

    If(Dropdown1.Selected.Value = "Yes", Set(var_output, "Text_1"),
    Dropdown1.Selected.Value = "No", Set(var_output, "Text_2"),
    Dropdown1.Selected.Value = "N/A", Set(var_output,Blank()))
     
  • Verified answer
    Mclean2023 Profile Picture
    79 on 26 May 2024 at 23:12:17
    Re: Set Variable from drop down

    need to make small update on this, need another option. When i update the formula, I don't get an error, but nothing happens when running it. the first part still works by adding no but if I change the drop down to yes, the no stays in the field.

     

    If(dropdown.SelectedText.Value = "No",Set(var_output , "TEXT_1") ||

    If(dropdown.SelectedText.Value = "Yes",Set(var_output , "TEXT_2") ||

    If(dropdown.SelectedText.Value="N/A",Set(var_output ,Blank())))

  • v-yueyun-msft Profile Picture
    on 23 May 2024 at 02:23:06
    Re: Set Variable from drop down

    Hi , @Mclean2023 

    Yes , you need to put this code to "OnChange" property which means Actions to perform when the user changes the value of a control (for example, by adjusting a slider).

    Drop down control in Power Apps - Power Apps | Microsoft Learn

     

    If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

     

  • Mclean2023 Profile Picture
    79 on 23 May 2024 at 02:17:02
    Re: Set Variable from drop down

    HI Yueyun

    PERFECT, thank you so much for your help and quick reply,

    If(dropdown.SelectedText.Value = "No",Set(var_output , "TEXT") ) worked. once i moved it to "on change" and not "on select"

  • v-yueyun-msft Profile Picture
    on 23 May 2024 at 02:00:25
    Re: Set Variable from drop down

    Hi , @Mclean2023 

    You can try to use this  code:
    If(dropdown.SelectedText.Value = "No",Set(var_output , "TEXT") )

     

    The ".Value" is the column Name in your dropdown control - items columnName;For example , if my items column Name is "Col1", i need to use this expression:
    If(dropdown.SelectedText.Col1= "No",Set(var_output , "TEXT") )

    vyueyunmsft_0-1716429768366.png

     

     

    If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading complete