Power Apps Formulas Quick Reference | elijah.ai

Power Apps Formulas Quick Reference

Power Apps Formulas Quick Reference

Why this exists: Microsoft's function reference is huge. You need the handful you use all the time, in one place.

For you if: You build canvas apps and keep forgetting the exact syntax for Patch or LookUp.

Ground truth: Condensed from Power Fx formula reference. Function details: Patch, Filter and LookUp, Collect and Clear.

Data: Create, Read, Update

FormulaWhat it doesExample
PatchCreate or update a recordPatch(Contacts, Defaults(Contacts), {FirstName: "Jane", Email: "jane@example.com"})
Patch (update)Update existing recordPatch(Contacts, LookUp(Contacts, Id = varCurrentId), {Status: "Active"})
CollectAdd rows to a collection (or create one)Collect(colItems, {Name: txtName.Text, Qty: 1})
ClearRemove all rows from a collectionClear(colItems)
RemoveDelete a recordRemove(Contacts, LookUp(Contacts, Id = ThisItem.Id))

Patch gotchas

  • Create: Patch(Datasource, Defaults(Datasource), {...}) — Defaults gives you a blank record to fill.
  • Update: Patch(Datasource, RecordToUpdate, {...}) — You need the record (often from LookUp or ThisItem).
  • Primary key: For create, some sources need you to specify the key. Check the table's requirements.

Data: Lookup and Filter

FormulaWhat it doesExample
LookUpSingle record matching criteriaLookUp(Contacts, Email = txtEmail.Text)
FirstFirst record from a table or filterFirst(Filter(Contacts, Status = "Active"))
FilterAll records matching criteriaFilter(Contacts, Status = "Active" && Region = "West")
CountRowsNumber of rowsCountRows(Filter(Contacts, Status = "Active"))
IsBlankTrue if null/emptyIsBlank(txtName.Text)

LookUp vs First: LookUp returns one record or blank. Use when you expect 0 or 1 match. First returns one record from a set. Use with Filter when you want "first of many." If nothing matches, First returns blank (and can cause errors if you dot into it).

Text and Numbers

FormulaWhat it doesExample
TextConvert to textText(Now(), "yyyy-mm-dd")
ValueConvert text to numberValue(txtQuantity.Text)
ConcatenateJoin strings"Hello, " & User().FullName
TrimRemove leading/trailing spacesTrim(txtInput.Text)
RoundRound a numberRound(12.456, 2) → 12.46

Conditions and Logic

FormulaWhat it doesExample
IfBranch on conditionIf(toggleOn.Checked, "Yes", "No")
SwitchMultiple conditionsSwitch(varStatus, "A", "Active", "P", "Pending", "Inactive")
CoalesceFirst non-blank valueCoalesce(txtOverride.Text, lblDefault.Text)

Context and Variables

FormulaWhat it doesExample
ThisItemCurrent item in gallery/listThisItem.Title
ThisRecordCurrent record in formThisRecord.Status
SetStore in variableSet(varSelectedId, ThisItem.Id)
UpdateContextStore in context variableUpdateContext({varCount: varCount + 1})

Set vs UpdateContext: Set is global for the screen. UpdateContext is for local context. For most app logic, Set is enough.

Galleries and Collections

FormulaWhat it doesExample
ItemsData source for galleryItems = Filter(Contacts, SearchTerm in Name)
SelectedSelected item in gallerySelected = galContacts.Selected
SortOrder rowsSort(Contacts, CreatedDate, Descending)
AddColumnsAdd calculated columnsAddColumns(Contacts, "FullName", FirstName & " " & LastName)

When Something Breaks

  • "Expecting a number": You passed text where a number was needed. Use Value().
  • "Invalid argument type": Wrong data shape. Check Filter/LookUp return types.
  • Delegation warning: Filter/Sort can't run on the server for that data source. Use delegable functions or LoadData limits. See delegation overview.

Microsoft Sources