Power Fx formulas with Syntax for canvas apps

Loading

Power Fx is a low-code language used in Microsoft Power Platform applications, including Power Apps. It’s designed to be easily understandable by users with diverse backgrounds. Here are some common Power Fx formulas along with their syntax and examples for use in Canvas Power Apps:

Syntax:

FunctionName(argument1, argument2, …)
Examples:
Concatenate: Concatenates strings.


Concat(“Hello”, ” “, “World”) // Outputs: “Hello World”
If: Returns one value if a condition is true and another if it’s false.


If( 5 > 3, “Five is greater than three”, “Five is not greater than three”) // Outputs: “Five is greater than three”
IsBlank: Checks if a value is blank.
IsBlank(TextField1.Text) // Returns true if TextField1 is blank, otherwise false
Switch: Evaluates a series of conditions and returns the result of the first one that is true.


Switch(
Dropdown1.Selected.Value,
“Option1”, “You selected Option 1”,
“Option2”, “You selected Option 2”,
“Option3”, “You selected Option 3”,
“None of the above”
)
Sum: Calculates the sum of numbers.


Sum(1, 2, 3, 4, 5) // Outputs: 15
Filter: Filters a table based on a condition.


Filter(DataSource, Column1 > 10)
CountIf: Counts the number of records in a table that satisfy a condition.


CountIf(DataSource, Column1 > 10)
LookUp: Finds the first record in a table that satisfies a condition.


LookUp(DataSource, Column1 = “Value”)
Today: Returns today’s date.


Today() // Outputs: Current date
Now: Returns the current date and time.


Now() // Outputs: Current date and time
Navigate: Navigates to a different screen.


Navigate(Screen2, ScreenTransition.Cover)
Set: Sets the value of a variable.


Set(VarName, “Value”)
Reset: Resets a control to its default state.


Reset(FormName)
ShowError: Displays an error message.


ShowError(“An error occurred.”)
SubmitForm: Submits a form.


SubmitForm(FormName)

Filter:

Syntax: Filter(Source, Formula)
Example: Filter(Employees, Department = “Sales”)
Description: Returns a table containing only the rows from the source table (e.g., SharePoint list, collection) that satisfy the given formula.
LookUp:

Syntax: LookUp(Source, Formula)
Example: LookUp(Employees, EmployeeID = 123)
Description: Returns the first record in a table that satisfies a formula.
Sort:

Syntax: Sort(Source, Formula)
Example: Sort(Employees, LastName)
Description: Returns a table sorted based on the specified column or columns.
Concatenate:

Syntax: Concatenate(Text1 [, Text2, …])
Example: Concatenate(“Hello”, ” “, “World”)
Description: Concatenates multiple text values into a single text value.
If:

Syntax: If(Condition, ValueIfTrue, ValueIfFalse)
Example: If(Sales > 1000, “High”, “Low”)
Description: Returns one value if a condition is true and another value if it’s false.
Switch:

Syntax: Switch(Expr, Value1, Result1 [, Value2, Result2, …] [, DefaultValue])
Example: Switch(DayOfWeek(), 1, “Sunday”, 2, “Monday”, …, 7, “Saturday”, “Unknown”)
Description: Evaluates a series of conditions and returns the corresponding result for the first condition that is true.
Sum:

Syntax: Sum(Table, Column)
Example: Sum(SalesData, Revenue)
Description: Calculates the sum of values in a column of a table or data source.
CountRows:

Syntax: CountRows(Table)
Example: CountRows(Employees)
Description: Returns the number of rows in a table or data source.
FirstN:

Syntax: FirstN(Source, Count)
Example: FirstN(Products, 5)
Description: Returns the first N rows of a table or data source.
LastN:

Syntax: LastN(Source, Count)
Example: LastN(Orders, 10)
Description: Returns the last N rows of a table or data source.
And:

Syntax: And(Condition1, Condition2, …)
Example: And(Sales > 1000, Revenue < 500)
Description: Returns true if all conditions are true; otherwise, returns false.
Or:

Syntax: Or(Condition1, Condition2, …)
Example: Or(Status = “Open”, Status = “Pending”)
Description: Returns true if any of the conditions are true; otherwise, returns false.

Leave a Reply

Your email address will not be published. Required fields are marked *