Power Apps Formulas and Functions Made Simple
Every action in a Power Apps canvas app — showing the right data, responding to a tap, saving a record, filtering a list — is powered by a formula. Formulas are short expressions written in the Power Fx language. Power Fx uses the same logic as Excel formulas, so if you have ever written =VLOOKUP() or =IF() in Excel, you already understand the pattern. This topic teaches you the formulas you will use in almost every app you build.
The Formula Bar: Where Formulas Live
Every control in a canvas app has multiple properties. A label has a Text property, a Color property, a Visible property, and many more. Every property can hold a formula — not just a static value. The formula bar at the top of Power Apps Studio is where you write formulas for the currently selected property of the currently selected control.
FORMULA BAR IN ACTION Control Selected: Gallery1 Property Selected: Items Formula Bar shows: Filter( 'Service Requests', Status = "Open" ) This means: The gallery shows only Service Request records where Status equals "Open". As data changes, the gallery updates automatically.
Click any control, then click any property in the Properties panel. The formula bar updates to show that property's current formula. Type to change it. Power Apps applies the change immediately — no compile step, no save required to see the effect.
Data Types: What Every Value Is
Power Fx formulas work with typed data. Every value has a type, and formulas must use the right type in the right place. Mixing types causes errors.
POWER FX DATA TYPES
┌─────────────┬─────────────────────────────┬──────────────────────┐
│ Type │ Example Values │ Common Use │
├─────────────┼─────────────────────────────┼──────────────────────┤
│ Text │ "Hello", "Delhi", "Open" │ Names, descriptions │
│ Number │ 42, 3.14, -100 │ Quantities, prices │
│ Boolean │ true, false │ Yes/No, on/off │
│ Date/Time │ Today(), Now() │ Dates, timestamps │
│ Record │ { Name: "Priya", Age: 30 } │ Single row of data │
│ Table │ Collection or data source │ Multiple rows │
│ Color │ Color.Red, RGBA(0,0,255,1) │ Control colors │
│ Blank │ Blank() │ Empty/null values │
└─────────────┴─────────────────────────────┴──────────────────────┘
The Most Important Formula Functions
IF: Making Decisions
IF is the most fundamental formula. It checks a condition and returns one value if true, another if false.
Syntax: If( Condition, TrueResult, FalseResult )
Examples:
If( Score >= 50, "Pass", "Fail" )
→ Returns "Pass" if Score is 50 or more, "Fail" if less
If( IsBlank(EmailInput.Text), "Email is required", "OK" )
→ Returns error message if the email box is empty
If( User().Email = "admin@company.com",
Color.Blue, // Admin sees blue header
Color.Gray // Others see gray header
)
Nested IF (check multiple conditions):
If( Priority = "High", Color.Red,
Priority = "Medium", Color.Orange,
Color.Green // else
)
FILTER: Finding the Right Records
Filter returns only records from a table that match one or more conditions. This is the formula you use in a gallery's Items property to show a subset of records.
Syntax: Filter( Table, Condition1, Condition2, ... ) Examples: Filter( 'Service Requests', Status = "Open" ) → Returns only Open requests Filter( Products, Category = "Electronics" And Price < 5000 ) → Electronics under ₹5,000 Filter( Employees, Department = DeptDropdown.Selected.Value ) → Employees matching the selected department in a dropdown Multiple conditions use And (both must be true) or Or (either must be true): Filter( Orders, Customer = "Priya" And Amount > 10000 ) Filter( Tasks, Status = "Urgent" Or DueDate < Today() )
SEARCH: Text-Based Filtering
Search filters records where a text column contains a keyword. Use it in combination with a Text Input control to build real-time search in a gallery.
Syntax: Search( Table, SearchString, "Column1", "Column2", ... ) Example on Gallery Items property: Search( Customers, SearchBox.Text, "FullName", "Email", "City" ) → As the user types in SearchBox, the gallery shows only customers whose name, email, OR city contains that text. → When SearchBox is empty, all customers appear.
PATCH: Saving Data
Patch creates a new record or updates an existing one in a data source. It is the most important formula for saving data.
Syntax:
Create new: Patch( DataSource, Defaults(DataSource), { Field: Value, ... } )
Update: Patch( DataSource, ExistingRecord, { Field: NewValue, ... } )
Example – Create a new Service Request:
Patch( 'Service Requests',
Defaults('Service Requests'),
{
Title: TitleInput.Text,
Priority: PriorityDropdown.Selected.Value,
Status: "Open",
'Created By': User().FullName
}
)
Example – Update just the Status of an existing record:
Patch( 'Service Requests',
Gallery1.Selected, // The currently selected record
{ Status: "Closed" } // Only this field changes
)
NAVIGATE: Moving Between Screens
Navigate moves the user to a different screen. Use it in button OnSelect formulas and gallery item OnSelect formulas.
Syntax: Navigate( Screen, Transition, { ContextVariable: Value } )
Examples:
Navigate( DetailScreen, ScreenTransition.Slide )
→ Go to DetailScreen with a slide animation
Navigate( EditScreen, ScreenTransition.Fade, { EditMode: true } )
→ Go to EditScreen and pass a context variable EditMode = true
ScreenTransition options:
None → Instant, no animation
Fade → Fades in
Cover → New screen slides over from right
Slide → Current screen slides away to left
UnCover → Current screen slides away
COLLECT and CLEARCOLLECT: Building Lists
Collect adds items to an in-memory collection. ClearCollect clears the collection first, then adds items. Use these for shopping carts, multi-item forms, and temporary data storage.
Collect( CartItems, { Product: "Laptop", Qty: 1, Price: 45000 } )
→ Adds one row to CartItems (keeps existing rows)
ClearCollect( CartItems, Filter('Products', Category = "Electronics") )
→ Resets CartItems, then fills it with Electronics products
Remove CartItems by condition:
Remove( CartItems, { Product: "Laptop" } )
Clear all items:
Clear( CartItems )
SORT and SORTBYCOLUMNS: Ordering Records
Sort( Customers, FullName ) → A to Z by name Sort( Customers, CreatedDate, SortOrder.Descending ) → Newest first SortByColumns( Customers, "City", SortOrder.Ascending, "FullName", SortOrder.Ascending ) → Sort by City first, then by Name within each city
LookUp: Finding One Record
LookUp finds the first record in a table that matches a condition. Use it when you need a single record rather than a list.
LookUp( Customers, CustomerID = "C-0001" ) → Returns the entire record for customer C-0001 LookUp( Products, ProductName = "Laptop" ).Price → Returns just the Price field of the Laptop record
Text Functions: Working With Words
Concatenate( "Hello, ", User().FullName, "!" ) → "Hello, Priya Sharma!" Upper( "hello" ) → "HELLO" Lower( "WORLD" ) → "world" Proper( "priya sharma" ) → "Priya Sharma" Left( "INV-2025-001", 3 ) → "INV" (first 3 characters) Right( "INV-2025-001", 3 ) → "001" (last 3 characters) Mid( "INV-2025-001", 5, 4 ) → "2025" (4 chars starting at position 5) Len( "Hello" ) → 5 (length of text) Text( 12345.6, "₹##,##0.00" ) → "₹12,345.60" (number formatting) Text( Today(), "DD MMM YYYY" ) → "04 Jun 2025" (date formatting)
Date and Time Functions
Today() → Current date (no time component) Now() → Current date AND time DateAdd( Today(), 7, TimeUnit.Days ) → 7 days from today DateAdd( Today(), -30, TimeUnit.Days ) → 30 days ago DateDiff( StartDate, EndDate, TimeUnit.Days ) → Number of days between two dates Year( Today() ) → 2025 Month( Today() ) → 6 Day( Today() ) → 4
IsBlank and IsEmpty: Checking for Nothing
IsBlank( TextInput1.Text ) → true if the text box is empty
IsBlank( Gallery1.Selected ) → true if nothing is selected in the gallery
If( IsBlank(EmailInput.Text),
Notify("Email is required", NotificationType.Error),
// proceed with saving
SubmitForm(Form1)
)
IsEmpty( CartItems ) → true if the collection has zero rows
NOTIFY: Showing Messages to Users
Notify shows a temporary message bar at the top of the screen — useful for success confirmations, warnings, and error messages.
Notify( "Record saved successfully!", NotificationType.Success ) Notify( "Email is required.", NotificationType.Error ) Notify( "This will be deleted. Are you sure?", NotificationType.Warning ) Notify( "Syncing data...", NotificationType.Information )
Chaining Formulas With Semicolons
A button's OnSelect formula often needs to do multiple things in sequence. Separate multiple formulas with a semicolon (or use the ; character in locales that use commas as decimal separators).
Button "Submit" OnSelect:
If( IsBlank(TitleInput.Text),
Notify("Title is required", NotificationType.Error),
// else: title is filled in, proceed
Patch( 'Service Requests',
Defaults('Service Requests'),
{ Title: TitleInput.Text, Status: "Open" }
);
Notify("Request submitted!", NotificationType.Success);
Navigate( BrowseScreen, ScreenTransition.Slide )
)
This formula:
1. Checks if title is blank
2. If blank: shows an error, stops
3. If filled: saves the record, shows a success message, then navigates away
Working With the Selected Record in a Gallery
When a user taps an item in a gallery, that item becomes Gallery1.Selected. Every field of the selected record is accessible through dot notation. This is the most common pattern for passing data from a list screen to a detail screen.
Gallery shows Service Requests. User taps on "Printer not working" row. On the Detail Screen, labels show: Title label Text property: Gallery1.Selected.Title Status label Text property: Gallery1.Selected.Status Priority label Text property: Gallery1.Selected.Priority Created label Text property: Text(Gallery1.Selected.'Created On', "DD MMM YYYY") The Edit Form's Item property: Gallery1.Selected (Form auto-populates all fields from the selected record)
Using Variables in Formulas
SET a global variable (available on all screens):
Set( ShowDeleteConfirm, false ) // Initialize to false
TOGGLE it on button click:
Set( ShowDeleteConfirm, true ) // Show confirmation dialog
USE it to control visibility:
DeleteConfirmDialog.Visible = ShowDeleteConfirm
RESET it after action:
Set( ShowDeleteConfirm, false ) // Hide dialog after delete
UPDATECONTEXT (local to current screen only):
UpdateContext( { IsEditing: true } )
Power Fx: The Underlying Language
Power Fx is the official name of the formula language used in Power Apps. Microsoft open-sourced it in 2021, meaning anyone can use or build tools with it. Power Fx is now expanding beyond Power Apps — it is appearing in Power Automate desktop flows, Copilot Studio bot formulas, and even Excel. Learning Power Fx now means your skills transfer to multiple tools across the Microsoft ecosystem.
Power Fx is "pure" by design — formulas describe relationships, not step-by-step instructions. When you write Gallery1.Items = Filter(Orders, Status = "Open"), you are saying "this gallery always shows open orders" — not "run this code now." The formula recalculates automatically whenever the underlying data changes. This reactive model makes Power Apps feel live and responsive without any manual refresh logic.
Key Points
- Every control property in Power Apps can hold a formula. Formulas make apps dynamic — they recalculate automatically as data and user interactions change.
- If checks conditions. Filter returns matching records from a table. Search filters by text keyword. LookUp returns one matching record.
- Patch creates or updates records. Navigate moves between screens. Notify shows user messages.
- Collect and ClearCollect manage in-memory collections. Sort and SortByColumns order records.
- Gallery1.Selected gives you the data of whichever row the user tapped — use it to populate detail screens and forms.
- Chain multiple formula actions with semicolons in a single property (like a button's OnSelect).
- Power Fx is the open-source language behind all Power Apps formulas — skills learned here transfer to other Microsoft tools.
