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 Platform Community / Forums / Power Apps / Using IF or Switch bas...
Power Apps
Answered

Using IF or Switch based on variable answer

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have a Variable(varLevels) that could have 3 conditions     "1" or "2" or "3"

 

If  varLevels  =  1 , do this 

    varlevels  = 2  , do this

   varLevels =  3  , do this

 

else  , do this 

 

Just looking to see what is the most efficient

 

Thanks

Dave 

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi!

     

    For your use case I would say the Switch is the most efficient since you won't need to have If statements inside other If statements, and you can use a default action (refering to the else {do this}). 


    Making your code more organized,clear to understand and easier to change if necessary!

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    The general rule on one over the other is - Use switch if your comparison is one-to-one.  Use If if you have to compare based on a formula.

     

    For example, if you are comparing one-to-one, then Switch:

    Switch(someValue,
     "Specific Value 1", <functions>,
     "Specific Value 2", <functions>,
     <functions> // ELSE - when no condition above is met
    )

     

    Using If:

    If(someValue > 10, <functions>,
     someValue > 5, <functions>,
     someValue = 4, <functions>,
     <functions> // ELSE when no conditions above are met
    )

     

    I hope this is helpful for you.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard