Power Apps Switch() — a practical guide (with real formulas)

Switch() in Power Apps (Power Fx) is the cleanest way to replace long chains of If(...) when you’re checking one value against multiple cases.

It reads like: “Given this value, if it matches case A return X, if it matches case B return Y, otherwise return default.”


1) What Switch() is (and why it’s useful)

When you write something like this:

If(
  x = "A", 1,
  x = "B", 2,
  x = "C", 3,
  0
)

…it works, but it becomes hard to maintain as cases grow.

Switch() solves that readability problem:

Switch(
  x,
  "A", 1,
  "B", 2,
  "C", 3,
  0
)


2) Syntax you need to memorize

Switch(
  valueToEvaluate,
  case1, result1,
  case2, result2,
  ...
  defaultResult
)

  • valueToEvaluate: any expression (text, number, boolean, etc.)
  • caseX: must be the same type as valueToEvaluate
  • defaultResult: strongly recommended (prevents blanks)

3) The most common real-world patterns

Pattern A — SharePoint Choice → compare .Value

SharePoint Choice fields usually come as a record, so you compare .Value.

Example: color a label based on a Choice field

// Label.Color
Switch(
  ThisItem.'Project Status'.Value,
  "New", Color.Gray,
  "In Progress", Color.Orange,
  "Done", Color.Green,
  Color.Red
)

Example: show a badge text

// Label.Text
Switch(
  ThisItem.Priority.Value,
  "High", "🔥 High",
  "Medium", "⚡ Medium",
  "Low", "✅ Low",
  "Unknown"
)


Pattern B — Navigation (menu / buttons)

// Button.OnSelect
Switch(
  ddMenu.Selected.Value,
  "Home", Navigate(scrHome, ScreenTransition.Fade),
  "Projects", Navigate(scrProjects, ScreenTransition.Fade),
  "Settings", Navigate(scrSettings, ScreenTransition.Fade),
  Navigate(scrHome, ScreenTransition.Fade)
)


Pattern C — Map friendly values to stored values (good for Patch)

This is super common when saving to SharePoint.

Example: map a dropdown to a numeric “Score”

Set(
  varScore,
  Switch(
    ddRating.Selected.Value,
    "Poor", 1,
    "OK", 2,
    "Good", 3,
    "Excellent", 4,
    0
  )
)

Then use varScore in your Patch().


Pattern D — Range / multi-condition logic using Switch(true, ...)

If you need “between” logic or compound conditions, use:

Switch(
  true,
  x < 0, "Invalid",
  x < 50, "Low",
  x < 80, "Medium",
  x <= 100, "High",
  "Out of range"
)

This pattern is extremely useful for:

  • validation
  • SLA/status rules
  • score bands

Pattern E — DataCard default values (Edit Form)

Example: default a text label based on a choice

// DataCardValue_Default.Text or Label.Text
Switch(
  Coalesce(DataCardValueStatus.Selected.Value, "New"),
  "New", "Please provide initial details",
  "In Progress", "Work is ongoing",
  "Done", "This item is completed",
  "No status"
)


4) Good habits (avoid bugs)

Always include a default

Without a default, the result becomes Blank() when no case matches — that causes UI glitches and Patch errors.

✅ Good:

Switch(x, "A", 1, "B", 2, 0)

⚠️ Risky:

Switch(x, "A", 1, "B", 2)

Ensure types match

  • If valueToEvaluate is a number, cases must be numbers.
  • If it’s a text, cases must be text.

Choice fields: use .Value

Common SharePoint mistakes:

  • ThisItem.Status (record)
  • ThisItem.Status.Value (text you can compare) ✅

5) When NOT to use Switch()

Use If() when:

  • you only have 1–2 conditions
  • you need short-circuit logic with heavy expressions

Use lookup tables (Collections / Dataverse tables) when:

  • the mapping will grow a lot and should be data-driven (e.g., 40+ cases)

6) Quick “copy/paste” recipes

Recipe 1 — Set a variable from multiple cases

Set(
  varStage,
  Switch(
    ThisItem.Stage.Value,
    "Intake", 1,
    "Design", 2,
    "Build", 3,
    "Test", 4,
    0
  )
)

Recipe 2 — Visible property control

// Control.Visible
Switch(
  varUserRole,
  "Admin", true,
  "Owner", true,
  false
)

Recipe 3 — Validate required fields by stage

Switch(
  true,
  ThisItem.Stage.Value = "Design" && IsBlank(txtDesignNotes.Text), false,
  ThisItem.Stage.Value = "Test" && IsBlank(txtTestPlan.Text), false,
  true
)


Step-by-step: how to use Switch() in your app

  1. Identify the one value you’re evaluating (dropdown selected value, SharePoint choice value, variable, etc.)
  2. Decide the cases (all the possible values)
  3. Decide the result for each case (color, text, navigation, numeric code)
  4. Add a default result (fallback)
  5. Test one case at a time

Summary tables

Steps summary

StepWhat you doResult
1Pick the value to evaluateYou know what drives the logic
2List the possible casesYou cover all expected options
3Define outputs per caseUI/logic becomes predictable
4Add a defaultNo unexpected blanks
5Test and refineFewer runtime surprises

Technical cheat-sheet

ScenarioBest patternExample value to evaluate
SharePoint ChoiceSwitch(ThisItem.Field.Value, ...)ThisItem.Status.Value
NavigationSwitch(dd.Selected.Value, ..., Navigate(...))ddMenu.Selected.Value
Ranges / complex conditionsSwitch(true, cond1, res1, ...)true
UI formattingSwitch(..., Color..., defaultColor)status/priority
Patch mappingSwitch(..., "Label", StoredValue, ...)dropdown/choice

Edvaldo Guimrães Filho Avatar

Published by