High-code isn’t the friendliest to new developers. Still, there are some high-code concepts that even low-code and no-code developers should be aware of. One such concept is conditional logic. Generalizing the idea, conditional logic helps the code determine its next steps based on data input.
Conditional logic is universal enough that it’s also leveraged in Microsoft Excel. If-Then conditions, many people’s go-to logic block, typically perform quick logic checks. If something is true, then do some series of actions. Otherwise, do some other series of actions:
if ([condition] == true) {
// do this
}
else {
// do this
}
Microsoft Power Fx, the formula language of the Power Platform, is a low-code programming language that makes uses of If-Then conditions, too:

Unfortunately, If-Then aren’t suitable for all conditions. In fact, they’re really just ideal for binary conditions, meaning there are just one or two choices to choose from. Whenever there are more than a few choices, If-Then conditions tend to become clunky, though that is relative. The logic still works, but for each additional choice, the condition has to reevaluate things, like determining which day of the work week today is:
if (vDayOfWeek === 1) {
// It's Monday!
}
else if (vDayOfWeek === 2) {
// It's Tuesday!
}
else if (vDayOfWeek === 3) {
// It's Wednesday!
}
else if (vDayOfWeek === 4) {
// It's Thursday!
}
else {
// It's Friday!
}

When evaluating multiple conditional choices, take advantage of the Switch function instead. Here, the condition doesn’t have to be evaluated more than once. Instead, it’s evaluated, then the result is compared against a series of possibilities. When the result finds a match, the logic performs its series of actions, then exits the logic block:
Switch([condition]) {
true:
// do this
break;
default:
// do this
}
Changing the day of the work week If-Then condition to a Switch function simplifies things. The value to be evaluated is calculated first, then possible matches are listed along with their respective series of actions:

Conclusion:
For binary decisions, If-Then conditions are great. For multiple decision paths, Switch functions are better. Not that If-Then conditions can’t get the job done, Switch functions are just more efficient when there are multiple branches for an evaluated result.
Imagine asking a group of 50 people to each solve an arithmetic problem, then polling each person individually to solve the equation and see whether their answer matches yours or not. That’s an If-Then condition. Now, imagine asking that same group to solve another problem, but instead of polling everyone individually, just ask out loud, “Who calculated 23? Raise your hands.” That’s faster, right? That’s a Switch function.
“Progress comes from caring more about what needs to be done than about who gets the credit.”
Dorothy Height
#BlackLivesMatter