web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Apps
Answered

switch function

(0) ShareShare
ReportReport
Posted on by Super User 2024 Season 1

Hi ,

I would to when i select on the payment method credit card the Status dropdown to select Closed please  

 

Thanks 

 

Annotation 2020-06-24 155413.pngAnnotation 2020-06-24 1554132.png

Categories:
I have the same question (0)
  • cchannon Profile Picture
    4,702 Moderator on at

    Not trying to be difficut, but have you checked out the documentation here?

  • Ramole Profile Picture
    Super User 2024 Season 1 on at

    Hi @cchannon 

    I Try but I am  confused can you please help me on this one 

     

    Thanks

  • cchannon Profile Picture
    4,702 Moderator on at

    Sure. OK, so you have two functions you might choose between here, and since you opened the post asking for Switch I'm gonna guess you already know that is the one you want to use, so we will just talk about Switch and not If...

    The advantage of using Switch over If is that you can write your condition criteria once, then apply it over many evaluation possibilities, instead of having to write If(<condition>, <outcome>) for every single one.

    So the Switch function has the following syntax: Switch(<formula>, Match1, Result1, Match2, Result2..., MatchN, ResultN)
    You can add as many possible matches and corresponding results as you want (but unlike C# and other language implementations of Switch you have no break operator so you will have to call out one result for one match every time).

    So let's try an example. Say we have a text input where a user types in another user's name and we want to control outcomes based on whose name they type in. Say the text field is called "UserName". If they enter CChannon, we then output True. Otherwise, if they enter Ramole, we output False. That Switch statement would look like this: 

    Switch(UserName.Text, "CChannon", True, "Ramole", False)

    We could keep going with this for as many possible conditions as we want to evaluate, so say instead of True/False we want to associate a number with each username, we might write: 

    Switch(USerName.Text, "CChannon", 1, "Ramole", 2, "UserX", 3, "UserY", 4)

     

    Does that help?

  • KrishnaV Profile Picture
    5,023 on at

    Hi @Ramole ,

     

    try this: Set it onChange of the Payment Method Dropdown

    Switch(paymentmethoddropdown.Selected.Text, "Credit Card", UpdateContext({varStVal:"Closed"}), "Debit Card", UpdateContext({varStVal:"Open"}))

     Now Set the variable varStVal as default value for status dropdown control.

     


    I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

    Regards,
    Krishna
    If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

  • Ramole Profile Picture
    Super User 2024 Season 1 on at

    Hi 

    Always getting error i dont know why , let me tell you what i am looking, example when payment method dropdown selected "Credit Card" and "Check"  The Status Dropdown = "Closed" and the rest should show "Open"

     

    Thanks

     

     

  • Ramole Profile Picture
    Super User 2024 Season 1 on at

    Hi 

     

    Is there anyone can help on this please how can make when user select dropdown payment method credit card, the pther dropdown status to auto select CLOSED 

     

    Thanks 

  • Verified answer
    KrishnaV Profile Picture
    5,023 on at

    Hi @Ramole ,

     

    Try this:

    If(dropdowncontrol.selected.value = "Check" || dropdowncontrol.selected.value = "Credit Card",updateContext({varSelStatus:"Closed"}),updateContext({varSelStatus:"Open"}))

    Now set the variable in the status dropdown for default selected Items property as below:

    {value:varSelStatus}


    I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

    Regards,
    Krishna
    If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 335 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 96 Super User 2026 Season 1

Last 30 days Overall leaderboard