Tutorials/Power Apps/Master Conditional Logic in Power Apps: An Expense Tracker Guide
Power Appsintermediate

Master Conditional Logic in Power Apps: An Expense Tracker Guide

Explore the true potential of the If function in Power Apps. Through a practical expense approval scenario, learn nested conditions, delegation patterns, and how to choose Switch over IF.

NA
Narmer Abader
@narmer · Published June 3, 2026

The If function is the foundation of dynamic logic in Power Apps. While most tutorials show isolated examples, real-world apps require you to weave conditions together seamlessly. In this guide, we will build the approval intelligence for an expense management system. You will see how If interacts with data sources, how to avoid deep nesting, and when to use Switch instead.

The Scenario: Contoso Expense Portal

We will design logic for a SharePoint list named ExpenseItems with these columns:

  • Title (Single line of text)
  • Amount (Currency)
  • Category (Choice: Travel, Software, Office Supplies, Meals)
  • Status (Choice: Draft, Submitted, In Review, Approved, Rejected)
  • SubmittedBy (Person or Group)

We will write formulas that power visibility rules, approval routing, and status display labels.

Simple Status Display

Instead of static text, we can make labels dynamic by checking the current state of an expense item.

powerfxStatus Label Display
If(
  ThisItem.Status = "Draft",
  "Waiting for employee to submit",
  ThisItem.Status = "Submitted",
  "Queued for review",
  ThisItem.Status = "In Review",
  "Under review by finance",
  ThisItem.Status = "Approved",
  "Payment processed",
  "Request was rejected"
)

Notice that when no condition matches, the function returns blank. Adding a final fallback string like "Unknown Status" ensures the label never appears empty.

Multi-Condition Approval Rules

An expense might require different approval levels based on the category and amount. For example, software purchases under $500 are auto-approved; over $500 needs IT; anything over $1,000 needs the CFO.

powerfxTiered Approval Routing
If(
  Category = "Software" && Amount <= 500,
  "Auto-Approved",
  Category = "Software" && Amount > 500,
  "Needs IT Director Approval",
  Amount > 1000,
  "Needs CFO Approval",
  "Needs Manager Approval"
)

Using && for compound conditions keeps your formula readable. Deeply nested If functions (If(A, If(B, If(C, ...)))) are harder to debug and should usually be refactored into flat conditions with &&.

Delegation and the If Function

A common request is a search box that shows all records when empty but filters when text is entered. This is elegantly solved with an If inside a Filter.

powerfxDelegation-Safe Search
Filter(
  ExpenseItems,
  If(
      TextSearchBox1.Text = "",
      true,
      Title = TextSearchBox1.Text
  )
)

When the search box is empty, the condition is true, which passes all rows through the filter. When text is entered, it filters by title. This delegation pattern works with SharePoint, SQL, and Dataverse as long as the condition itself can be delegated (e.g., no untyped columns in the branch).

Delegation warnings

Power Apps Studio flags non-delegable formulas with a yellow triangle warning icon in the formula bar, and non-delegable expressions are underlined in blue. Hover over either indicator to see the delegation warning message. By default, Power Apps fetches only the first 500 records (adjustable up to 2,000 in app settings). If your list has more rows and your formula cannot be delegated, results will be silently incomplete.

When to Use Switch Instead of If

The first example (status display) checks a single value against many possibilities. The Switch function is specifically designed for this scenario and is more concise.

powerfxRefactored Status with Switch
Switch(
  ThisItem.Status.Value,
  "Draft", "Waiting for employee to submit",
  "Submitted", "Queued for review",
  "In Review", "Under review by finance",
  "Approved", "Payment processed",
  "Rejected", "Request was rejected",
  "Unknown Status"
)

Use Switch when you have one expression and many possible results. Use If when you have multiple distinct conditions to evaluate.

Error Handling with IfError

Wrapping Patch in IfError prevents silent failures and keeps the user informed. IfError(Value, Fallback) runs the Fallback only when Value produces an error — so chain your success notification inside the first argument using a semicolon, then put the error handler as the second argument.

powerfxGraceful Error Handling
IfError(
  // First argument: the operation + success notification (both run when Patch succeeds)
  Patch(ExpenseItems, Gallery1.Selected, {Status: "Approved"});
  Notify("Expense approved successfully", NotificationType.Success),

  // Second argument: runs only when an error occurs
  Notify("Update failed: " & FirstError.Message, NotificationType.Error)
)
Common mistake

Placing the success Notify as the second argument is a frequent error — that position is the error handler. The success path must be chained (;) inside the first argument so it only executes when no error occurs.

Common Mistakes and How to Avoid Them

  1. Omitting the false result: If you leave out the final argument, If returns blank when all conditions are false. This can break text labels or comparisons elsewhere.
  2. Over-nesting: Flatten your logic with && or || operators.
  3. Type mismatch: Comparing a text string to a number always results in false. Use Value() on text inputs or Text() on numbers before comparing.
  4. Delegation traps: Be careful when using non-delegable functions inside the branches of an If used in a Filter. For example, Filter(DataSource, If(cond, col = x, AddColumns(...))) will pull back all records locally.

Final Recommendation

Start by writing your condition in plain English. Identify if you are checking several different conditions (use If) or one value against many matches (use Switch). Validate your logic with representative data before releasing to production.

Pro Tip

Draw your logic tree on a whiteboard before writing a single line of Power Fx. A visual map of your condition flow makes it much easier to spot missing branches or redundant checks.

References