Browse all topics
Power Platform

Power Fx primer

A practical introduction to Power Fx, the formula language used across Power Apps and the Power Platform.

Power Fx is the formula language used across Power Apps canvas apps, increasingly in Power Automate, Dataverse formula columns, Copilot Studio, and Microsoft Fabric. Modelled on Microsoft Excel formulas, it's declarative, strongly-typed, and designed for non-developers. Learning a small Power Fx subset unlocks much of the Power Platform.

The mental model

A Power Fx formula is an expression — it evaluates to a value. You bind expressions to control properties: a button's OnSelect, a label's Text, a gallery's Items, a field's default value.

Excel users will find much familiar:

  • Sum(Numbers, Value) totals a column.
  • If(condition, then, else) conditional logic.
  • Concatenate(A, " ", B) string joining (modern equivalent: the & operator).
  • Filter(Customers, Status = "Active") filters a table.
  • LookUp(Orders, OrderID = thisID) finds a single row.

Core functions

A handful of functions cover most scenarios:

  • Filter(table, condition) — return rows matching a condition.
  • LookUp(table, condition) — return the first row matching a condition (or a specific field of it).
  • Sort(table, expression) — sort.
  • SortByColumns(table, "Column", SortOrder.Descending) — sort with explicit direction.
  • First(table) / Last(table) — first / last row.
  • Count(table) / CountRows(table) — count.
  • Sum(table, expression) — total an expression across rows.
  • Patch(table, baseRecord, updateRecord) — update a row in a data source.
  • Collect(collection, item) — add to a local collection.
  • ClearCollect(collection, source) — replace a collection.
  • UpdateContext({var: value}) — set local variables.
  • Set(GlobalVar, value) — set global variables.

Working with data

Connect a canvas app to a data source (SharePoint, Dataverse, SQL), and the source appears as a table you query with Power Fx:

// On a gallery's Items property:
SortByColumns(
  Filter(Customers, Status = "Active" && Region = ddRegion.Selected.Value),
  "Name",
  SortOrder.Ascending
)

That's a complete query of an Active customers filtered by selected region and sorted by name — all in one expression.

Variables and scope

Three variable scopes:

  • Context variables (UpdateContext) — scoped to the current screen.
  • Global variables (Set) — scoped to the whole app.
  • Collections (Collect, ClearCollect) — table-shaped local data.

Use the right scope. Globals are tempting but make the app harder to reason about. Prefer context variables when possible.

Delegation

A critical concept: delegation is when Power Fx pushes a filter/sort back to the data source's server (SharePoint, SQL, Dataverse) rather than fetching everything and filtering client-side. Without delegation, your app might fetch only the first 500 rows and filter those — missing data the user expects.

The Power Apps editor warns when a formula isn't fully delegable. Pay attention; rewrite the formula to use delegable operators where possible.

Common patterns

  • If(IsBlank(field), "Required", "") — show a validation message.
  • Patch(Datasource, Defaults(Datasource), {Field1: value1, Field2: value2}) — create a new record.
  • Navigate(NextScreen, ScreenTransition.Cover) — go to another screen.
  • Reset(Control) — reset a control to its default.

Learning approach

The fastest way to learn Power Fx: build a simple app from a SharePoint list, then progressively add filter, sort, search, edit, delete. Each step uses a few more Power Fx functions and patterns. In a week of regular practice, the basics stick.

For developers coming from imperative languages, the declarative model takes adjustment — Power Fx isn't sequential statements; it's expression bindings that recalculate when their dependencies change. Treat it like a spreadsheet, not like JavaScript.