0% found this document useful (0 votes)
23 views14 pages

Power App Formulas.!-1

The document outlines important Power App formulas, detailing their use cases and example scenarios for each. Key formulas include Set() for global variables, UpdateContext() for context variables, and various functions for data manipulation such as LookUp(), Filter(), and Sort(). Additionally, it covers conditional logic, user input validation, and navigation between screens.

Uploaded by

naveencrm456
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views14 pages

Power App Formulas.!-1

The document outlines important Power App formulas, detailing their use cases and example scenarios for each. Key formulas include Set() for global variables, UpdateContext() for context variables, and various functions for data manipulation such as LookUp(), Filter(), and Sort(). Additionally, it covers conditional logic, user input validation, and navigation between screens.

Uploaded by

naveencrm456
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Important Power App Formulas

1 1⃣ Set() – Global Variables

📌 Use Case: Store values globally and access them across multiple screens.

Set(varUserName, TextInput1.Text)

➡ Scenario: Store the logged-in user’s name and display it on another screen.

2⃣ UpdateContext() – Context Variables

📌 Use Case: Store values locally within a screen.

UpdateContext({varScreenMessage: "Welcome!"})

➡ Scenario: Show a temporary success message on the screen after an action.

3⃣ If() – Conditional Logic

📌 Use Case: Perform conditional operations.

If(TextInput1.Text = "", "Please enter a value", "Valid Input")

➡ Scenario: Validate user input before submission.

4⃣ LookUp() – Fetch a Single Record

📌 Use Case: Retrieve a specific record from a data source.

LookUp(Employees, EmployeeID = Dropdown1.Selected.ID, Name)

➡ Scenario: Get an employee’s name based on the selected ID in a dropdown.


5⃣ Filter() – Retrieve Multiple Records

📌 Use Case: Fetch multiple records based on a condition.

Filter(Employees, Department = "HR")

➡ Scenario: Display only HR department employees in a gallery.

6⃣ Distinct() – Remove Duplicates

📌 Use Case: Get unique values from a column.

Distinct(Employees, Department)

➡ Scenario: Populate a dropdown with unique department names.

7⃣ Concat() – Combine Multiple Values

📌 Use Case: Merge multiple values into a single string.

Concat(Employees, Name & ", ")

➡ Scenario: Display all employee names as a comma-separated list.

8⃣ Patch() – Update or Insert Records

📌 Use Case: Save new data or update existing records in Dataverse.

Patch(Employees, Defaults(Employees), {Name: TextInput1.Text, Department:


Dropdown1.SelectedText})

➡ Scenario: Add a new employee record when a user submits a form.


9⃣ Navigate() – Screen Navigation

📌 Use Case: Move between screens in the app.

Navigate(Screen2, ScreenTransition.Fade)

➡ Scenario: Go to Screen2 with a fade transition when a button is clicked.

🔟 Collect() & ClearCollect() – Store Data in Collections

📌 Use Case: Temporarily store data in collections.

ClearCollect(colEmployees, Employees)

➡ Scenario: Load employees into a collection for offline usage.

✨ Bonus: Sort() – Sort Records

📌 Use Case: Sort records in ascending/descending order.

Sort(Employees, Name, Ascending)

➡ Scenario: Display employees alphabetically.

1 1⃣ Switch() – Multiple Conditional Checks

📌 Use Case: Simplifies multiple If() conditions.

Switch(Dropdown1.Selected.Value,
"HR", "Human Resources",
"IT", "Information Technology",
"Finance", "Finance Department",
"Unknown"
)

➡ Scenario: Display full department names based on the selected value from a dropdown.
2⃣ IsBlank() & IsEmpty() – Check for Empty Values

📌 Use Case: Validate input fields or check if a collection is empty.

If(IsBlank(TextInput1.Text), Notify("Please enter a value",


NotificationType.Error))

➡ Scenario: Prevent submission of an empty form field.

If(IsEmpty(Employees), Notify("No employees found",


NotificationType.Warning))

➡ Scenario: Show a warning if there are no records in the Employees table.

3⃣ User() – Get Logged-in User Information

📌 Use Case: Retrieve details of the currently logged-in user.

User().FullName

➡ Scenario: Auto-fill the logged-in user’s name in a form.

User().Email

➡ Scenario: Display the user’s email for authentication purposes.

4⃣ StartsWith() – Search Records Efficiently

📌 Use Case: Filter records as the user types.

Filter(Employees, StartsWith(Name, TextSearchBox1.Text))

➡ Scenario: Implement real-time search functionality in a gallery.

5⃣ EndsWith() – Filter Based on Ending Text


📌 Use Case: Find records where a column ends with a specific value.

Filter(Employees, EndsWith(Email, "@company.com"))

➡ Scenario: Display only employees with company email addresses.

6⃣ Remove() & RemoveIf() – Delete Records

📌 Use Case: Delete data from a collection or table.

Remove(Employees, LookUp(Employees, EmployeeID = SelectedItem.ID))

➡ Scenario: Delete a selected employee record.

RemoveIf(Employees, Department = "HR")

➡ Scenario: Delete all employees in the HR department.

7⃣ Update() – Modify an Existing Record

📌 Use Case: Update an existing record without replacing the entire row.

Update(Employees, LookUp(Employees, EmployeeID = 123), {Name: "John Doe",


Salary: 60000})

➡ Scenario: Update an employee’s salary without affecting other fields.

8⃣ ForAll() – Apply an Action to Each Item in a Collection

📌 Use Case: Perform batch operations.

ForAll(Employees, Patch(Employees, ThisRecord, {Salary: Salary * 1.1}))

➡ Scenario: Give all employees a 10% salary hike.


9⃣ Rand() – Generate Random Numbers

📌 Use Case: Create random values for testing or unique identifiers.

Rand() * 100

➡ Scenario: Generate a random discount between 0 and 100%.

"EMP-" & Round(Rand() * 10000, 0)

➡ Scenario: Generate a unique employee ID.

🔟 DateAdd() – Add or Subtract Time from Dates

📌 Use Case: Manipulate dates dynamically.

DateAdd(Today(), 30, Days)

➡ Scenario: Show the due date 30 days from today.

DateAdd(Today(), -7, Days)

➡ Scenario: Display the date 7 days ago.

🎯 Summary of These 10 Formulas

Formula Purpose Example Use Case


Switch() Replaces multiple If() Show full department names based
conditions on selection
IsBlank() / Checks if a field or table is Validate input before submission
IsEmpty() empty
User() Gets current user details Auto-fill logged-in user’s name
StartsWith() Filters data dynamically Real-time search in a gallery
EndsWith() Finds records with specific Filter emails ending in
ending text @company.com
Remove() / Deletes records Remove selected employees from
RemoveIf() HR department
Update() Updates an existing record Change an employee’s salary
ForAll() Loops through a collection Apply a salary increase for all
employees
Rand() Generates random numbers Assign unique IDs
DateAdd() Adds or subtracts time from Set expiry dates dynamically
dates

1 1⃣ Text() – Format Text & Dates

📌 Use Case: Convert numbers/dates into a specific format.

Text(Now(), "dd-mm-yyyy hh:mm:ss")

➡ Scenario: Display the current date and time in day-month-year format.

Text(Value(TextInput1.Text), "[$-en-US]$#,##0.00")

➡ Scenario: Format a number as currency.

2⃣ Value() – Convert Text to Number

📌 Use Case: Convert a string into a numeric value for calculations.

Value("123") + 10

➡ Scenario: Perform arithmetic operations on user input stored as text.

3⃣ Match() – Validate Text Using Regular Expressions

📌 Use Case: Validate input formats (e.g., emails, phone numbers).

If(Match(TextInput1.Text, "\d{10}"), "Valid Phone Number", "Invalid")


➡ Scenario: Ensure the user enters a 10-digit phone number.

If(Match(TextInput1.Text, "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-
Z]{2,4}$"), "Valid Email", "Invalid")

➡ Scenario: Validate email input.

4⃣ Split() – Convert a String into a Table

📌 Use Case: Extract values from a comma-separated string.

Split("Apple,Banana,Orange", ",")

➡ Scenario: Convert a comma-separated list into a collection.

Filter(Employees, emp_desig in Split(ComboBox1.Selected.emp_desig, ","))

➡ Scenario: Filter employees based on multiple selected designations.

5⃣ Table() – Create a Temporary Table

📌 Use Case: Store temporary static data.

Table({ID: 1, Name: "John"}, {ID: 2, Name: "Alice"})

➡ Scenario: Show a quick list without using a database.

6⃣ GroupBy() – Group Data by a Column

📌 Use Case: Categorize data into groups.

GroupBy(Employees, "Department", "GroupedData")

➡ Scenario: Show employees grouped by department.


GroupBy(SalesData, "Region", "SalesByRegion")

➡ Scenario: Summarize sales by region.

7⃣ Ungroup() – Convert Grouped Data Back to Normal

📌 Use Case: Flatten a grouped dataset.

Ungroup(SalesByRegion, "SalesData")

➡ Scenario: Show the original list of sales records.

8⃣ Sum() – Calculate the Total of a Column

📌 Use Case: Aggregate numeric data.

Sum(Employees, Salary)

➡ Scenario: Calculate the total salary expense.

Sum(Sales, Revenue)

➡ Scenario: Show the total revenue.

9⃣ Average() – Find the Average Value

📌 Use Case: Calculate the mean of a dataset.

Average(Employees, Salary)

➡ Scenario: Display the average salary of employees.

Average(StudentScores, Score)
➡ Scenario: Calculate students' average test scores.

🔟 CountRows() & CountIf() – Count the Number of Records

📌 Use Case: Count records with or without conditions.

CountRows(Employees)

➡ Scenario: Show the total number of employees.

CountIf(Employees, Department = "HR")

➡ Scenario: Show the number of employees in HR.

🎯 Summary of These 10 Formulas

Formula Purpose Example Use Case


Text() Format numbers & dates Show dates in dd-mm-yyyy format
Value() Convert text to a number Convert input for calculations
Match() Validate text using regex Ensure email & phone number
format
Split() Convert string to table Break comma-separated values
Table() Create a table manually Store temporary data in an app
GroupBy() Group data by a field Group employees by department
Ungroup() Convert grouped data Show original list from grouped
back data
Sum() Get the sum of a column Calculate total salary/revenue
Average() Find the average of a Show average salary or test scores
column
CountRows() & Count records Count total employees or filter-
CountIf() based

1 1⃣ Patch() – Add, Update, or Modify Records in a Data Source

📌 Use Case: Save form data into a Dataverse table.


Patch(Employees, Defaults(Employees), {Name: "John", DeptID: 5})

➡ Scenario: Add a new employee with Name = John and DeptID = 5.

Patch(Employees, LookUp(Employees, ID = 101), {Salary: 75000})

➡ Scenario: Update salary for an existing employee with ID = 101.

2⃣ Remove() – Delete a Record from a Data Source

📌 Use Case: Delete selected employee from a gallery.

Remove(Employees, Gallery1.Selected)

➡ Scenario: Remove the selected employee from the Employees table.

3⃣ RemoveIf() – Delete Records Based on a Condition

📌 Use Case: Delete employees who have resigned.

RemoveIf(Employees, Status = "Resigned")

➡ Scenario: Remove all resigned employees from the database.

4⃣ Collect() – Store Data in a Collection

📌 Use Case: Save user selections into a temporary list.

Collect(SelectedProducts, {ProductID: 101, Name: "Laptop"})

➡ Scenario: Store selected product details for checkout.

Collect(TempData, Employees)

➡ Scenario: Store all employee records in a temporary collection.


5⃣ ClearCollect() – Clear and Then Store New Data

📌 Use Case: Refresh data before storing new records.

ClearCollect(TempData, Filter(Employees, DeptID = 5))

➡ Scenario: Fetch only employees from DeptID = 5 into a temporary collection.

6⃣ Sort() – Sort Data in Ascending or Descending Order

📌 Use Case: Sort employees by name.

Sort(Employees, Name, Ascending)

➡ Scenario: Display the employee list alphabetically.

Sort(Employees, Salary, Descending)

➡ Scenario: Show highest-paid employees first.

7⃣ SortByColumns() – Dynamic Sorting Based on Column Name

📌 Use Case: Sort dynamically using dropdown selection.

SortByColumns(Employees, Dropdown1.Selected.Value, Ascending)

➡ Scenario: Allow users to sort employees by Name, Salary, or Department dynamically.

8⃣ Lookup() – Fetch a Single Record from a Table

📌 Use Case: Get Department Name using DeptID (foreign key).


LookUp(Departments, DeptID = EmployeeGallery.Selected.DeptID, Name)

➡ Scenario: Show Department Name in an Employee Form.

LookUp(Employees, ID = 102, Salary)

➡ Scenario: Retrieve salary of Employee ID 102.

9⃣ Search() – Search Text Within a Table

📌 Use Case: Search employees by name.

Search(Employees, TextInput1.Text, "Name")

➡ Scenario: Filter the employee list based on user input.

🔟 Navigate() – Move Between Screens

📌 Use Case: Navigate from Home screen to Employee Details screen.

Navigate(EmployeeDetailsScreen, ScreenTransition.Fade)

➡ Scenario: Open the Employee Details screen with a fade transition.

🎯 Summary of These 10 Formulas

Formula Purpose Example Use Case


Patch() Add/Update data Save a new employee or update a
record
Remove() Delete a record Remove selected employee
RemoveIf() Delete records Remove all resigned employees
conditionally
Collect() Store data in a collection Save selected products for checkout
ClearCollect() Clear & add new data Refresh and store employee list
Sort() Sort data Sort employees alphabetically
SortByColumns() Dynamic sorting Allow users to choose sort order
LookUp() Fetch a single record Get department name from DeptID
Search() Search text in data Search employees by name
Navigate() Move between screens Open Employee Details screen

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy