0% found this document useful (0 votes)
6 views

Power Apps

Microsoft Power Apps is a low-code platform for developing custom business applications that connect to various data sources. It offers three types of apps: Canvas Apps, Model-driven Apps, and Portals, each with unique functionalities. Power Fx is the formula language used in Power Apps, supporting various data types, operators, and functions for efficient app development.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Power Apps

Microsoft Power Apps is a low-code platform for developing custom business applications that connect to various data sources. It offers three types of apps: Canvas Apps, Model-driven Apps, and Portals, each with unique functionalities. Power Fx is the formula language used in Power Apps, supporting various data types, operators, and functions for efficient app development.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 42

Power Apps

Introduction to Microsoft Power Apps


 Power Apps is used to develop some custom business apps for your organization.
 It is also known as a low code tool that users can use to build an app.
 Power Apps helps to build applications that connect to several data sources in various online
and on-premises as Office 365, SharePoint, Excel, SQL Server, Microsoft Azure, Dynamic 365,
JIRA, OneDrive, Power BI, and so on.
 it helps to connect the external data sources directly inside the app.
 Once your app is ready, you can publish it and share it with your team members in your
organization.
 By using Power Apps, you can easily and quickly build your business apps which is responsive
in designs.
 This app is user-friendly and works in any Browser (Microsoft IE11, Google Chrome, and
Microsoft Edge) and any mobile device like phone or tablet.

In Power Apps, we can create three types of Apps:


1. Canvas Apps
2. Model-driven App
3. Portal (power Pages)

1) Canvas App :

 Blank canvas
 Drag and drop different controls on a screen
 You can design a pixel perfect design with custom colors and theme
 Create multiple screens for different functionalities and reusable components
 If you are good with excel formulas, you might find it bit easy to work with Canvas app,
because Power Apps uses Power Fx functions/formulas
 You can connect with more than 400 connectors
 No code/low code

Reference: https://learn.microsoft.com/en-us/power-apps/maker/canvas-apps/getting-started

2) Model Driven App:

 Model driven apps are data driven apps


 You can add forms, views, charts, dashboards
 All model-driven apps offer a similar user interface

Reference: https://learn.microsoft.com/en-us/power-apps/maker/model-driven-apps/model-driven-
app-overview

3) Portals / Power Pages

 Internal or external-facing websites


 Allow users outside their organizations to sign in with a wide variety of identities
 Browse content anonymously

Reference: https://learn.microsoft.com/en-us/power-apps/maker/portals/overview
in power apps, what is environment
A Power Apps Environment is a container that holds apps, data, flows, and other resources. It helps
in organizing, securing, and managing Power Platform solutions within a Microsoft tenant.

In Power Apps, an environment is a logical container that groups apps, data, and resources together.
It provides boundaries for data management, security, and governance within the Microsoft Power
Platform.

Default Environment → Automatically created for each tenant; shared by all users.
Production Environment → Used for live apps with full functionality.
Sandbox Environment → Used for development and testing.
Trial & Developer Environments → Temporary environments for personal testing or learning.

Each environment has specific security roles and policies to control access.
Each environment has its own Dataverse, apps, flows, and connectors.

Power Fx:
Operators and Identifiers
. (Dot) Operator in Power Fx
The dot (.) operator in Power Fx is used to access properties of objects, records, or controls.
It allows you to retrieve values from tables, collections, records, and controls efficiently.
1️. Accessing Control Properties
You can use the dot operator to access a control’s property, such as Text, Value,
Selected, etc.
TextLabel.Text = TextInput1.Text //This assigns the text entered in TextInput1 to TextLabel.
Button1.Fill //Retrieves the background color of Button1.

2. Accessing Record Fields in a Table


The dot operator allows you to get a specific field from a record in a table.
Employees. Name // Returns: ["Alice", "Bob", "Charlie"] (A list/column of all names in the
Employees table)
// Extracting employee names from a table. If Employees is a table, this retrieves the Name
field from all records
Lookup(Employees, ID = 101).Salary // Getting a specific record’s value. Finds the employee
with ID = 101 and returns their Salary.
3.Using Dot Operator in Collections
Collections are like tables, and the dot operator is used to access specific fields.
ClearCollect(Products, Table(
{Name: "Laptop", Price: 1200},
{Name: "Phone", Price: 800}
))
First(Products).Price
This returns 1200, the price of the first product.
4. Accessing Global and User Information
The dot operator helps fetch system and user-related data.
Example: Getting the logged-in user’s name
User().FullName // Returns the current user’s full name.
Example: Getting the current date
Today().Year //Extracts the year from today’s date.
Arithmetic Operators (Used for calculations)

Mod( Number, Divisor )


Power( Base, Exponent )
Comparison Operators (Used to compare values)

Logical Operators (Used for conditions)

String Operators (Used for text operations)


"hello" & " " & "world"
Table Operators

in and exactin operators


Both in and Exactin are used for checking whether a value exists in a table, collection, or list.

The in operator is used to check if a value exists in a table, collection, or list. It performs
case-insensitive matching, meaning it doesn't care about whether letters are uppercase or
lowercase.

"Bob" in Employees. Name //Returns true if "Bob" exists in the Name column of the
Employees table.
5 in [1, 2, 3, 4, 5] //Returns true because 5 is in the list.
LookUp(Employees, Name = "Bob") in Employees //Returns true if there is a record with
the name "Bob" in the Employees table.

The Exactin operator checks if a value exists in a table, collection, or list, but it performs
case-sensitive matching.
"bob" Exactin Employees. Name //Returns false if the Employees. Name column contains
"Bob", because Exactin requires an exact case match, and "bob" is different from "Bob".

"Apple" Exactin ["apple", "banana", "orange"] //Returns false


ThisItem, ThisRecord, and As Operators in Power Fx
These operators are essential for working with dynamic data in Power Apps, especially when
dealing with galleries, forms, and tables/records.

ThisItem Operator in Power Fx


The ThisItem operator is commonly used in Galleries, Forms, or any context where you're
dealing with a collection of records. It refers to the current item/record being processed or
displayed.
 ThisItem references the current item in a Gallery or Form (or any repeating control).
 It allows you to access the properties or fields of the current record that is being
displayed in the UI.
Label1.Text = "Name: " & ThisItem. Name
Label2.Text = "Age: " & Text(ThisItem. Age)

Both ThisItem and ThisRecord are operators used to reference records in Power Fx, but they
are used in different contexts. Understanding the difference between them is important for
working effectively in Power Apps, especially when dealing with controls like Galleries,
Forms, and tables/collections.

Identifiers in Power Fx
In Power Fx, identifiers are names used to reference variables, controls, collections, data
sources, fields, and columns. They help uniquely identify elements within an app.
1. Simple Identifiers (No Spaces or Special Characters)
If an identifier does not contain spaces or special characters, use it directly.
Example: Accessing a Column in a Table
Employees. Name //Retrieves the Name field from the Employees table.
2. Escaped Identifiers (Containing Spaces or Special Characters)
If an identifier contains spaces, special characters, or starts with a number, enclose
it in single brackets [ ].
Example: Accessing a Column with Spaces
'[Employee Details]'.Salary // References the Salary column from the Employee
Details table.
3. Identifiers in Nested Tables
When working with nested tables or records, use the . (dot) operator to access fields.
Example: Accessing Nested Records
Employees.Manager.Name // Retrieves the Manager's Name from the Employees
table.
4. Identifiers in Collections
When working with collections, reference the collection name followed by field
names.
Example: Getting the First Record in a Collection
First(Employees).Name // Retrieves the Name of the first employee in the Employees
collection.
Power Fx Data Types
Power Fx supports a variety of data types for working with text, numbers, records, tables,
and more. Understanding these data types helps you build efficient Power Apps.

If( Score > 50, "Pass", "Fail" )


Record: Represents a single row of data (like an object).
{ Name: "Alice", Age: 30, Salary: 50000 }
varEmployee.Name // Outputs: "Alice"

Table
 Represents a collection of records (like a database table)
Employees = [
{ Name: "Alice", Age: 30 },
{ Name: "Bob", Age: 40 }
]
First(Employees).Name

Date & Time


Today() // Returns current date
Now() // Returns current date and time
Date(2024, 4, 1) // Returns April 1, 2024

Text(Now(), "dd-mm-yyyy") // Outputs "02-04-2025"

Currency
 Stores monetary values.
$100.50
Text(100.5, "$#,###.00") // Outputs "$100.50"

GUID (Unique Identifier)


 Used for generating unique IDs.
GUID() // Generates a unique ID

ImageControl.Image = https://example.com/image.jpg

Set(varEmployee,
{
Name: "Alice",
Age: 30,
Salary: 50000,
JoiningDate: Date(2020, 5, 10),
IsActive: true
}
)
Date Handling in Power Fx

Text(Today(), "dd-mmm-yyyy") // "02-Apr-2025"


Creating a Date
Use Date(year, month, day) to define a specific date.
Example: Date(2024, 4, 1) // Returns "01-Apr-2024"

Text(Today(), "mmmm") // "April"


Text(Date(2023, YourMonthNumber, 1), "mmmm")

Weekday(Today(), StartOfWeek.Sunday) //👉 Returns: 4 (If today is Wednesday)


DateAdd(Today(), 30, Days) //👉 Returns: 30 days from today’s date
DateDiff(Date(2000, 1, 1), Today(), Years) //👉 Returns: 25 (if today is 2025)

Time Handling in Power Fx


display current time only
Text(Now(), "hh:mm:ss AM/PM")

Hour(Now()) // Returns: 14
Text(Now(), "hh:mm AM/PM") // "02:30 PM"
Text Handling in Power Fx
Left("Microsoft", 3) // "Mic" // Get the First 3 Characters
Mid("PowerFx", 3, 4) // "werF" // Extract Middle Part of a Text
Trim(" Hello ") //”Hello” // Remove Spaces

Find Position of "F" in "PowerFx"


Find("F", "PowerFx") //6
Check if a String Starts with "Power"
StartsWith("PowerFx", "Power") //true

Replace "old" with "new"


Substitute("old text", "old", "new") // "new text"
Number Handling in Power Fx

 Int rounds down to the nearest integer.


 Trunc truncates the number to just the integer portion by removing any decimal
portion.
The difference between Int and Trunc is in the handling of negative numbers. For
example, for an argument of -4.3, Int will return the integer further away from zero, -
5, while Trunc will return the integer closer to zero, -4.

RandBetween(1, 10) // A random number between 1 and 10


Rand() // 0.4578 (varies each time Random Decimal Between 0 and 1)

If(Amount > 100, "Over Budget", "Within Budget")


Text(1500, "$#,###") //$1,500
Price - (Price * DiscountPercentage / 100)
👉 If Price = 100 and DiscountPercentage = 20,
👉 Output: 80 (after 20% discount)

IsBlank(TextInput1.Text) // Returns true if the input is empty.


Set(MyVar, Blank());
IsBlank(MyVar) // Returns true
IsBlank("") // Returns false! Because "" is an empty string, not a true blank.

What is Blank()?
 Blank() is the equivalent of null in other programming languages.
Blank() // Returns a blank (null) value
Set(MyVar, Blank()) //Clears the variable, setting it to "no value."
UpdateContext({MyInput: Blank()}) //Can be used to clear or reset inputs bound to context
variables.
If(MyVar = Blank(), "It's empty", "Has value")
If(IsBlank(MyVar), "It's empty", "Has value")

What Does IsEmpty() Do?


IsEmpty(table)
🔹 Returns true if the table or collection has zero rows
🔹 Returns false if there is at least one row
Check if a collection is empty
IsEmpty(MyCollection)
Check if search results are empty
IsEmpty(Filter(Products, Price > 1000))
If no products match the condition, this returns true.
If(IsEmpty(MyCollection),
Notify("No data found", NotificationType.Warning),
Navigate(DetailsScreen)
)
Tables in Power Fx
In Power Fx, a table is a collection of records (rows) with multiple fields (columns). Tables
allow you to store and manipulate structured data, similar to an Excel spreadsheet or a
database table.

🔹 1. Create a Table Using Table() (Static Data)


Set(
MyTable,
Table(
{ ID: 1, Name: "Alice", Age: 30 },
{ ID: 2, Name: "Bob", Age: 35 },
{ ID: 3, Name: "Charlie", Age: 28 }
)
)
 Set() stores the table in a variable.
 Each row is a record ({}), and all rows are inside Table(...).
You can use MyTable directly in galleries, dropdowns, etc.

🔹 2. Connect to a Real Data Source (SharePoint, Excel, SQL, etc.)


If you want a persistent table:
1. Go to Data on the left menu in Power Apps studio.
2. Click + Add data.
3. Choose your source (e.g., SharePoint, Excel on OneDrive, Dataverse).
4. Select or create a table/list.
5. Now you can use it in your app — e.g., Items = '[YourDataSource]'.
🔍 What is LookUp?
LookUp searches a table and returns the first record that matches a condition. You can
return the whole record or just a single field.

LookUp( Table, Condition [, FieldToReturn] )


 Table: Where you're searching (like a collection or SharePoint list)
 Condition: The logic to find the match
 FieldToReturn: (optional) Just return one field instead of the whole record
🔹 1. Return a Full Record
LookUp(Employees, ID = 101)
Gets the entire record from Employees where ID = 101.

🔹 2. Return a Specific Field


LookUp(Employees, ID = 101, Name)
Gets just the Name of the employee with ID = 101

🔹 3. With a SharePoint List


If you have a SharePoint list called Products:
LookUp(Products, ProductCode = "A101", Price)
Returns the price of the product with code "A101".

LookUp(Employees, Name = "Alice" && Status = "Active", ID)


LookUp(Tasks, Title = "Submit Report" And Status = "Completed", DueDate)
LookUp(Products, Category = SelectedCategory && Price <= MaxPrice, Name)

LookUp(Employees, ID = 1).Email
LookUp(Employees, ID = 1).Department

You can’t return multiple fields directly as values in the third argument (like LookUp(..., ...,
Name, Email))
LookUp(Employees, ID = 1, Name, Email) ❌

AddColumns, DropColumns, RenameColumns, and ShowColumns


functions
AddColumns function in Power Apps
it's used to add a new column to a table or collection, often based
on a formula using existing data and returns new dataset as table
or collection.

ClearCollect(
Employees,
{ FirstName: "Alice", LastName: "Smith" },
{ FirstName: "Bob", LastName: "Jones" }
);
ClearCollect(
EmployeesWithFullName,
AddColumns(
Employees,
"FullName", FirstName & " " & LastName
)
)
Nested AddColumns
AddColumns(AddColumns(Employees,Tax,salary*0.30),NetSalary,Salary-
Tax)

DropColumns
Removes one or more columns from a table.
DropColumns(SourceTable, "Column1", "Column2", ...)
DropColumns(Employees, "Email", "Phone")
Removes Email and Phone from each record in the Employees table.

RenameColumns
🔤 Renames columns in a table. Useful when working with SharePoint or
data sources that return unfriendly names.
RenameColumns(SourceTable, "OldName1", "NewName1", "OldName2",
"NewName2")
RenameColumns(Employees, "FullName", "Name", "Dept", "Department")
Renames FullName to Name, and Dept to Department.

ShowColumns
Selects only specific columns to keep — like a filter for columns.
ShowColumns(SourceTable, "Column1", "Column2", ...)
ShowColumns(Employees, "Name", "Email")
Keeps only Name and Email columns, drops everything else.
number of records in a table or collection in Power Apps, use the CountRows() function.
CountRows(CollectionName)

If(IsBlank(LookUp(Employees, Name = "John")),


Collect(Employees, { Name: "John", Department: "IT", Salary: 6000 })
)
(OR)
RemoveIf(Employees, Name = "John");
Collect(Employees, { Name: "John", Department: "IT", Salary: 6000 });
If(IsBlank(LookUp(Employees, Name = "Sara")),
Patch(Employees, Defaults(Employees),{ Name: "Sara", Department: "HR", Salary: 5500 } )
)

If(
IsBlank(LookUp(Employees, Name = "John")),
Collect(Employees, { Name: "John", Department: "IT", Salary: 6000 }),
Patch(Employees, LookUp(Employees, Name = "John"), { Department: "IT", Salary: 6000 })
)

What Does Remove Do?


The Remove() function deletes specific record(s) from a collection or data source.
Remove(DataSourceOrCollection, Record1 [, Record2, ...])

Example 1: Remove selected record from a gallery


Remove(Employees, Gallery1.Selected) //Removes the record the user clicked on in a
gallery.
Example 2: Remove multiple specific records
Remove(Employees, First(Employees), Last(Employees))
Removes the first and last records from the Employees collection.
Bonus Tip: Remove a record by searching for it
Remove(Employees, LookUp(Employees, Name = "John"))
This finds and removes the First Record with employee named John.
Example 3: Remove a specific record
Remove(Employees, { Name: "John", Department: "IT", Salary: 6000 })
❌ This works only if the record matches exactly — field names and values.

🔹 What is RemoveIf?
RemoveIf() removes records from a collection or data source that match a condition.
Think of it like: "Delete all records where X is true."
RemoveIf(Source, Condition)
 Source = your collection or data source (e.g. Employees)
 Condition = a logical test (e.g. Department = "HR")
📌 Example 1: Remove all records in the HR department
RemoveIf(Employees, Department = "HR")
🧹 Deletes all employees who work in HR.
📌 Example 2: Remove a specific person by name
RemoveIf(Employees, Name = "Alice")
🔍 Deletes all records where the name is Alice.
📌 Example 3: Remove based on multiple conditions
RemoveIf(Employees, Department = "IT" && Salary > 6000)
📉 Deletes IT employees making more than 6000.

🔍 What is Filter?
The Filter() function lets you display or work with only the records that meet certain
conditions — super useful with galleries, collections, data tables, and more.
Filter(Source, Condition1 [, Condition2, ...])
 Source = your collection or data source (like Employees, Products, Orders)
 Condition = any logical test (like Department = "HR", Price > 100, etc.)
🔹 Example 1: Get all HR employees
Filter(Employees, Department = "HR")
🔍 Returns only employees whose department is HR.
🔹 Example 2: Filter products over $500
Filter(Products, Price > 500)
🛒 Great for showing premium items in a gallery.
🔹 Example 3: Multiple conditions (AND)
Filter(Employees, Department = "IT", Salary > 6000)
🧠 Returns IT employees earning more than 6000.
🔹 Example 4: Use with a gallery
Items: Filter(Employees, Department = "Sales")
💼 Shows only sales staff in your gallery.
Bonus: Use User().Email for personalization
Filter(Orders, CreatedBy = User().Email)
🔐 Shows only records created by the current user.

🔹 What is Search?
The Search() function filters a table based on a text search — like searching for a name, title,
or keyword.

✅ It’s case-insensitive, and it checks if the search text is contained within the specified
column(s).

Search(Source, SearchText, ColumnToSearch)


 Source: Your data source or collection (like Employees, Products)
 SearchText: The value you're searching for (usually from a TextInput)
 ColumnToSearch: The column where Power Apps should look
📌 Example 1: Search employee names
Search(Employees, TextSearchBox1.Text, "Name")
➡️Returns all employees whose Name contains the text entered.
📌 Example 2: Search products by title
Search(Products, TextInput1.Text, "Title")
➡️Great for building a searchable product catalog.
🔥 Use it in a Gallery
Set your gallery’s Items property to:
Search(Employees, TextSearchBox1.Text, "Name")
Now your gallery updates live as the user types!

🔹 What is Sort?
The Sort() function sorts a table or collection based on the values in a specific column.
Sort(Source, ColumnName, SortOrder)
 Source: Your data source or collection (e.g., Employees, Products)
 ColumnName: The column you want to sort by (e.g., "Name", "Salary")
 SortOrder: Use Ascending or Descending
📌 Example 1: Sort employees by name (A to Z)
Sort(Employees, Name, Ascending)
➡️Names will appear in alphabetical order.

📌 Example 2: Sort products by price (High to Low)


Sort(Products, Price, Descending)
➡️Most expensive products appear first.
💡 Combine Sort with Search or Filter
You can sort filtered or searched data too:
Sort(
Search(Employees, TextSearchBox1.Text, "Name"),
Name,
Ascending
)
🔄 This creates a searchable and sorted gallery!

🔹 What is SortByColumns?
SortByColumns() sorts a table or collection by one or more column names (provided as text)
and allows for dynamic sorting (using variables).

SortByColumns(Source, "ColumnName", SortOrder)


 Source: Your data source or collection (e.g., Employees)
 "ColumnName": The name of the column, in quotes
 SortOrder: Ascending or Descending
📌 Example 1: Sort Employees by Name (A to Z)
SortByColumns(Employees, "Name", Ascending)
📋 Alphabetically sorts the employee names.
📌 Example 2: Sort Products by Price (High to Low)
SortByColumns(Products, "Price", Descending)
💰 Shows most expensive products first.
📌 Example 3: Sort by Multiple Columns
SortByColumns(Employees, "Department", Ascending, "Name", Descending)
📂 First sorts by Department, then by Name within each department.
📌 Example 4: Dynamic Sort Order with a Variable
Let’s say you have a toggle or button that sets a variable called sortAsc:
SortByColumns(Employees, "Salary", If(sortAsc, Ascending, Descending))
✅ Sorts ascending or descending based on user interaction.
GUID in Power Fx
A GUID (Globally Unique Identifier) is a 128-bit unique identifier used to ensure that each
record or object has a distinct value. GUIDs are often used as primary keys in databases to
uniquely identify records.
Collections in Power Apps
A Collection is a type of temporary in-memory table in Power Apps. It's used to store data
locally during a user session — great for storing, editing, and reusing data across screens
without a database.

✅ Why Use Collections?


 Store user input or dynamic data temporarily
 Display items in galleries or forms
 Collect data offline
 Modify or manipulate data without updating your backend

1. Creating a Collection
👉 Using Collect()
Collect(Students, { Name: "Alice", Age: 20 }, { Name: "Bob", Age: 22 })
🟢 Creates a collection named Students with two records.
👉 Using ClearCollect()
ClearCollect(Students, { Name: "Charlie", Age: 25 })
🟢 Clears existing data in Students and adds one new record.
ClearCollect(Countries,”india”,”USA”,”UK”)
First(Countries).Value
Use UpdateIf to modify records.
UpdateIf(MyCollection, ID = 1, {Name: "Alice Cooper"})
7. Storing Nested Data
You can store tables within collections.

Collect(MyCollection,
{ID: 1, Name: "Alice", Skills: Table({Skill: "Power Apps"}, {Skill: "Power Fx"})}
)
Table vs. Collection in Power Fx

You might also like