These are essential building blocks for developing and modeling powerful applications and solutions. The good news is, mastering these concepts isn’t as intimidating as it seems, especially with the right examples and approach.

Table of Contents

Part I: Understanding Collections

A collection in Power Apps is essentially a group or set of related items, similar to an array. These items can be records, numbers, strings, or any other data item. Collections offer a flexible and intuitive means to manage and manipulate data.

To create a collection, we use the Collect function. For example:

Collect(ProductCollection, {ProductName: “Product A”, Price: 20},
{ProductName: “Product B”, Price: 30})

Here, ProductCollection is a new collection that consists of two items, each representing a product. Each product item is a record that consists of ProductName and Price.

To update an existing collection, we use the Collect function again, specifying the existing collection’s name. For example:

Collect(ProductCollection, {ProductName: “Product C”, Price: 40})

After this operation, ProductCollection now includes an additional item for Product C.

To clear the collection, you can use the Clear function.

Clear(ProductCollection)

Fast and efficient, collections provide a way to work with groups of similar items in Power Apps.

Part II: Understanding Variables

Variables represent a placeholder for a value, similar to variables in programming. That value can be static (a hard-coded number or string, for example), or it can be dynamic (such as the current time or the result of an operation).

There are different types of variables in Power Apps:

  • Global variables: These are accessible throughout the entire app. They are created by using the Set function, for instance: Set(VarType, "Basic").
  • Context variables: These are only available on the screen where they are created or to any screens that are navigated to from there. They are created by using the UpdateContext function, for instance: UpdateContext({VarType: "Advanced"}).
  • Collection variables: These are a bit more complex and versatile than the above two kinds of variables. They hold a collection of values. They are created by using the Collect function, for instance: Collect(VarType, {Name: "Type A", Value: 100}).

Comparing Collections vs Variables

Collections Variables
What they hold Multiple items Single value
Scope Whole app Whole app (global) or specific screens (context)
Use cases Hold related items together Hold values that change over time

In conclusion, Collections and Variables are critical aspects of the PL-100 Microsoft Power Platform App Maker exam. Understanding these concepts and how to implement them effectively can go a long way to achieving a passing score on the exam.

Practice Test

You can create a collection in Power Apps by using the ‘Collect’ function.

• A. True

• B. False

Answer: A. True

Explanation: The ‘Collect’ function in Power Apps can be used to create a collection, effectively an array of data or set of records.

Can you use variables in Power Apps to store and manipulate data temporarily?

• A. Yes

• B. No

Answer: A. Yes

Explanation: Variables in Power Apps are used to store and manipulate data temporarily. They can exist either globally (app-wide) or locally (on a specific screen).

Which of the following are considered types of variables in Power Apps?

• A. Global Variables

• B. Context Variables

• C. Collection Variables

• D. Local Variables

Answer: A. Global Variables, B. Context Variables

Explanation: In Power Apps, there are Global Variables which are app-wide, Context Variables which are specific to a screen or a specific control. Collection Variables and Local Variables do not exist in Power Apps

Collections in Power Apps are permanent storage and data persists even after closing the app.

• A. True

• B. False

Answer: B. False

Explanation: Collections are temporary tables and they exist only till the app is running. Data will be lost once the app is closed unless it has been saved to a data source.

‘Clear’ function in Power Apps is used to empty a collection.

• A. True

• B. False

Answer: A. True

Explanation: The ‘Clear’ function in Power Apps can be used to completely remove all the items from a collection.

Which of the following functions is used to update data in a specific record of a collection in Power Apps?

• A. Collect()

• B. Update()

• C. Patch()

• D. Clear()

Answer: C. Patch()

Explanation: The Patch function is used to modify one or more records in a data source, or to create a record if one does not already exist.

Can you use the ‘Set’ function in Power Apps to create a Global variable?

• A. Yes

• B. No

Answer: A. Yes

Explanation: The ‘Set’ function in Power Apps is used to create a Global variable.

Only one value can be stored in a variable in Power Apps.

• A. True

• B. False

Answer: B. False

Explanation: You can store a single scalar value, a record (set of named values), or a table (set of records) in a variable.

It’s possible to assign default values to variables in Power Apps.

• A. True

• B. False

Answer: A. True

Explanation: You can assign a default value to a variable using the ‘Set’ or ‘UpdateContext’ function.

‘Remove’ function is used to remove a specific item from a collection.

• A. True

• B. False

Answer: A. True

Explanation: The ‘Remove’ function in Power Apps is used to remove specific items from a collection.

In Power Apps, you can add an item to a collection but you cannot remove an item from a collection.

• A. True

• B. False

Answer: B. False

Explanation: You can add as well as remove items from a collection using the ‘Collect’ and ‘Remove’ functions respectively.

The ‘UpdateIf’ function updates all entries in the collection which match a certain criteria.

• A. True

• B. False

Answer: A. True

Explanation: The ‘UpdateIf’ function in Power Apps updates all records in a collection or a data source that satisfy a specified condition.

It is mandatory to save the data of a collection to a data source before closing the app.

• A. True

• B. False

Answer: B. False

Explanation: It is not mandatory to save the data of a collection to a data source before closing the app, but if you want the data to persist after the app is closed, you’ll need to save it to a data source.

Can you use collection in Power Apps to store data from multiple sources?

• A. Yes

• B. No

Answer: A. Yes

Explanation: Yes, you can use a collection in Power Apps to consolidate data from multiple sources into one place.

In Power Apps, collections allow data to be stored and manipulated without a backend database.

• A. True

• B. False

Answer: A. True

Explanation: Collections allow data to be stored and manipulated within the app itself, eliminating the requirement of a backend database.

Interview Questions

What is the purpose of collections in Power Apps?

Collections are used in Power Apps to temporarily store data that can be used in the app or shared with other apps.

How to create a collection in Power Apps?

Collections can be created using the “collect” function. e.g., Collect(ProductCollection, {Name: “Laptop”, Price: 500})

What is the use of variables in Power Apps?

Variables in Power Apps are used to store values temporarily which can be used or manipulated later in the app.

How to define a variable in Power Apps?

You can define a variable using the “Set” function. e.g., Set(variableName, value)

Can you modify a collection after it is created in Power Apps?

Yes, you can modify a collection using functions like “Update”, “Remove”, or “ClearCollect” in Power Apps.

What is the difference between a global variable and a contextual variable in Power Apps?

A global variable is accessible from anywhere within the app while a contextual variable is only accessible from the screen where it was created.

How to clear a collection in Power Apps?

Collections can be cleared using the “Clear” function. e.g., Clear(ProductCollection)

How to remove an item from a collection in Power Apps?

You can remove an item from a collection using the “Remove” function. e.g., Remove(ProductCollection, ThisItem)

How to update an item in a Collection in Power Apps?

You can update an item using the “Update” function. e.g., Update(ProductCollection, ThisItem, {Name: “New Laptop”, Price: 600})

What is the purpose of the “UpdateIf” function in Power Apps?

The “UpdateIf” function updates records in a collection or a data source that meet certain criteria.

How to use a variable in a button click in Power Apps?

You can use a variable on a button click using the “OnSelect” property of the Button.

What is the function to view all the collections in your Power App?

The Collections function, which can be accessed from the File menu in Power Apps, enables you to view all collections.

What is the purpose of the ForAll function in Power Apps?

The ForAll function evaluates a formula for all records of a table.

How to use the Collect function to create a collection from a SharePoint list?

The Collect function can create a collection from a SharePoint list. E.g., Collect(Products, SharePointList)

What is the maximum size of a collection or variable in Power Apps?

The maximum size is 2000 items per collection or variable in Power Apps due to a delegation limit. However, this limit can be changed in the settings.

Leave a Reply

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