Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Set Variable from drop down

Posted on 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
    Mclean2023 79 on at
    Re: Set Variable from drop down

    Thank you so much, that worked perfectly

  • Verified answer
    MuhammadAizaz Profile Picture
    MuhammadAizaz 44 on at
    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
    Mclean2023 79 on at
    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())))

  • 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
    Mclean2023 79 on at
    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"

  • 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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,487

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,014

Leaderboard