PowerApps Tutorial: How to Use The Most Common Functions

Thumbnail image for "Tutorials" article

Table of contents

In this tutorial, we’ll walk through some of the most common functionality used in PowerApps. These functions are essential to building efficient and user-friendly applications.

Whether you’re just starting out or want to improve your skills, this guide will help you understand how to apply these functions to your project.

The Functions

1) Patch 

Applies to: 

  • Canvas apps 
  • Model-driven apps 
  • Power Platform CLI 
  • Desktop flows 

Usage: 

The Patch function is used to modify or create records in a data source. It allows developers to update specific fields of an existing record without affecting other fields or to create a new record in the data source. 

Syntax: 

Patch(DataSource, RecordToModify, Changes) 

For example, to create a new record: 

Patch(DataSource, Defaults(DataSource), {FieldName1: Value1, FieldName2: Value2}) 

Importance: 

The Patch function is crucial for submitting changes to data sources, especially in scenarios where only a part of the record needs to be updated. It's used in forms and custom functions to handle data updates and additions. 

2) LookUp 

Applies to: 

  • Canvas apps 
  • Desktop flows
  • Model-driven apps 
  • Power Pages 
  • Power Platform CLI

Usage: 

The LookUp function is used to search for a single record that matches specific criteria in a data source and returns that record. 

Syntax: 

LookUp(DataSource, Condition, [ResultField]) 

Example: 

LookUp(Employees, EmployeeID = 123, Name) 

Importance: 

The LookUp function is essential for retrieving a specific record or value from a dataset, often used for filling fields with data based on another field’s value (e.g., filling in customer details after selecting a customer ID). 

3) Search 

Applies to: 

  • Canvas apps 
  • Desktop flows 
  • Model-driven apps 
  • Power Pages 
  • Power Platform CLI 

Usage: 

The Search function allows you to find records in a data source based on a text search on specific fields. 

Syntax: 

Search(DataSource, SearchString, ColumnName, ColumnName2, …)

Example: 

Search(Products, “Laptop”, “ProductName”) 

Importance: 

The Search function is widely used in creating search boxes that help users find records by entering keywords. It's especially useful in scenarios where quick text-based lookups are needed. 

4) ClearCollect 

Applies to: 

  • Canvas apps 
  • Model-driven apps

Usage: 

The ClearCollect function combines two actions: clearing any existing data in a collection and then collecting a new set of data. 

Syntax: 

ClearCollect(CollectionName, DataSource) 

Example: 

ClearCollect(ProductList, Filter(Products, Category = “Electronics”)) 

Importance: 

The ClearCollect function is important when managing data within an app session. It helps reset and refresh a local data set to ensure the app works with updated data. 

5) Collect 

Applies to:

  • Canvas apps 
  • Cards 
  • Dataverse low-code plug-ins 
  • Power Platform CLI 
  • Desktop flows

Usage: 

The Collect function is used to add data to a collection without clearing any existing data. 

Syntax: 

Collect(CollectionName, DataSource or Record) 

Example: 

Collect(ProductList, {ProductName: “New Laptop”, Price: 1500}) 

Importance: 

The Collect function is essential for creating and maintaining temporary data collections (data stored in memory for use during the app session), often used for scenarios like shopping carts or temporary data manipulation. 

6) Filter 

Applies to: 

  • Canvas apps 
  • Desktop flows 
  • Model-driven apps 
  • Power Pages 
  • Power Platform CLI 

Usage: 

The Filter function is used to find records in a data source that meet a specific condition. It returns a table that contains the matching records.

Syntax: 

Filter(DataSource, Condition) 

Example: 

Filter(Products, Price > 1000) 

Importance: 

The Filter function is key to narrowing down data sets based on conditions, allowing users to view only the data that’s relevant to them. It’s often used in galleries or forms to display filtered data dynamically. 

7) If 

Applies to: 

  • Canvas apps 
  • Dataverse formula columns 
  • Desktop flows 
  • Model-driven apps 
  • Power Pages 
  • Power Platform CLI 

Usage: 

The If function is used to evaluate a condition and return one value if the condition is true and another value if it's false. 

Syntax: 

If(Condition, TrueResult, FalseResult) 

Example: 

If(Price >1000, “Expensive”, “Affordable”) 

Importance: 

The If function is a core conditional function that enables logic branching in apps. It's used to display specific values or perform actions depending on the result of an evaluated condition.

Conclusion

By applying these common PowerApps functions, you’ll be able to create more effective and responsive applications. As you become more familiar with these tools, you’ll find it easier to design apps that meet your needs and streamline your workflow.

Looking for more tips? You may find these tutorials useful:

  1. How to Create a Collapsible Side-Navigation Menu
  2. How to Create a Pop Up
  3. How to Use Components