Teaching Power Fx: Read, Check and Fix Formulas

—

You can access the helper tool to validate some parts of your formula from here.

Part 1: Anatomy of a formula

Show this formula and label each part with the class:

Filter(Orders, Status = "Open" && Total > 100)
  • Filter is the function. Everything inside its brackets is an argument, separated by commas.
  • Orders is a table. Status and Total are columns.
  • = compares two values. Power Fx uses a single equals sign. && means “and”. > means “greater than”.
  • "Open" is text, so it sits in double quotes.

Then introduce the extra pieces learners will meet: records such as {Name: "A", Qty: 2}, chaining formulas with ;, comments starting with //, and single quotes for names that contain spaces, such as 'Order Date'.

Ask: what would change if we removed the quotes around Open? Power Apps would stop treating it as text and look for something named Open.

Part 2: Find a function

Open the Function reference tab. Show learners how to search by what they want to do, for example “date” or “remove”, and how to read the syntax line, description and example on each card.

Give these four tasks. Learners find the function, copy the example and adapt it.

TaskAnswer
Show the first 3 characters of a nameLeft(txtName.Text, 3)
Total of Price times Qty across the cartSum(colCart, Price * Qty)
The date seven days from todayDateAdd(Today(), 7, TimeUnit.Days)
Count the open ordersCountIf(Orders, Status = "Open")

The Use in checker button sends an example straight to the second tab, which is a good way to move into Part 3.

Part 3: Debug with the checker

Learners paste each formula into the Check and format tab, press Check, select each finding to jump to it, fix the formula and check again until the tool reports no problems.

#FormulaWhat the checker reportsFix
1If(txtName.Text == "", Notify("Name is required"), Set(varOk, true))Error: use a single = signReplace == with =
2Filter(Orders, Status != "Open")Error: use <> for not equalReplace != with <>
3Notify(“Saved”)Two errors: curly quotesRetype as Notify("Saved") with straight quotes
4Left("Power Apps")Warning: Left expects 2 arguments but found 1Left("Power Apps", 5)
5If(IsBlank(txtName.Text), Notify("Enter a name", NotificationType.Error)Error: missing a closing )Add ) at the end
6if(IsBlank(txtName.Text), "Missing", "OK")Warning: if( is not in the function list, did you mean IfChange if to If
7Lenn(txtName.Text)Warning: did you mean LenChange Lenn to Len

Discuss:

  • Why is #4 a warning and not an error? The tool compares against its own list of functions, which can be incomplete or out of date, so it asks the learner to confirm rather than declaring a failure.
  • Why fix the first error first? One missing bracket can make later parts of the formula look wrong too.
  • Where do curly quotes in #3 come from? Usually from copying text out of a web page or a document.

Part 4: Make it readable

Paste this unformatted formula. It has no problems, so Check reports nothing. Now press Format.

ForAll(colOrders,Patch(Archive,Defaults(Archive),{Title:Title,Total:Total*1.2,Status:If(Total>1000,"Large","Small")}))

The expected result:

ForAll(
colOrders,
Patch(
Archive,
Defaults(Archive),
{
Title: Title,
Total: Total * 1.2,
Status: If(Total > 1000, "Large", "Small")
}
)
)

Ask:

  • What does this formula do? For every order it adds a new record to Archive, with the same title, the total plus 20 percent, and a status of Large or Small.
  • How do we know formatting did not change the meaning? It only changes spaces and line breaks. Learners can compare the two versions piece by piece.
  • Which version would you rather debug at 5 pm on a Friday?

Activity: pairs swap one of their own formulas, format it, then explain it back to the author.

Part 5: What the checker cannot catch

Paste this formula. The tool reports no problems:

If(Value(txtAge.Text) > 18, "Adult", "Minor")

Ask: who is wrongly called a Minor? Someone who is exactly 18. The fix is >=. The formula was valid but wrong.

The teaching point: a checker finds syntax mistakes. Only testing finds logic mistakes. Other things this tool cannot see:

  • A misspelled control, column or variable name.
  • Text where a number is needed, or the other way round.
  • Delegation limits, where a large data source is only partly processed.
  • Regional settings that change the separators.

Activity: learners write three test values (17, 18 and 19) and the expected result for each, then try them in Power Apps.

Part 6: Quick quiz

QuestionAnswer
Which operator tests whether two values are equal?A single =
How do you write “not equal”?<>
What does ; do between two formulas?Runs them one after the other
What does Patch(Orders, Defaults(Orders), {Title: "New"}) do?Creates a new record in Orders
What does the formatter change?Spacing and line breaks only

Common misconceptions

  • “== is for equality.” Power Fx uses a single =.
  • “No errors means the formula is correct.” It only means the syntax looks fine.
  • “Set and UpdateContext are the same.” Set makes a variable every screen can use. UpdateContext makes one for the current screen.
  • “Double and single quotes are interchangeable.” Double quotes hold text. Single quotes wrap names that contain spaces.
  • “Formatting fixes broken formulas.” It only changes layout, and it refuses to run if brackets or quotes are unbalanced.

Assessment ideas

  • Use the Part 6 quiz as a five-point check.
  • Take-home task: give each learner a broken formula of about five lines. They fix it, format it and explain in two sentences what it does.
  • Suggested rubric: finds every problem (50 percent), correct fixes (30 percent), clear explanation (20 percent).
  • Extension: write a formula that counts the open orders owned by the current user. One valid answer is CountRows(Filter(Orders, Status = "Open", Owner = User().Email)).

Limits of the tool

  • It does not run formulas. Always test in Power Apps.
  • The function list covers about 100 common functions. A function outside the list gets a note, not an error, because it may still be valid.
  • Argument counts come from the tool’s own list. Microsoft may change a function, so confirm against the official documentation when the tool and Power Apps disagree.
  • It assumes English (US) separators: a comma between arguments and a semicolon between formulas. Some regional settings use different ones.
  • It is not made by or affiliated with Microsoft.

Leave a Reply

● About Me

Hi! I’m Ayush Purohit — a tech enthusiast who loves building solutions, exploring new tools, and sharing practical tips. This blog is where I break down complex concepts into simple, actionable advice to help you learn, experiment, and grow in your tech journey.

Discover more from Learning By Doing | Unlocking Power Platform

Subscribe now to keep reading and get access to the full archive.

Continue reading