Power Apps - First steps with variables Tutorial

Unlock the power of variables in Power Apps with 'First Steps with Variables.' Discover how global, local variables, and collections can enhance your app development process. Learn practical applications and formulas to manage dynamic information effectively. Join us for a low-code journey that transforms your app creation experience, perfect for both beginners and advanced users!

  • 04:26
  • 0 views
00:00:05
used to temporarily hold values within the application.
00:00:10
Its primary purpose lies in its ability to retain,
00:00:13
modify and reuse dynamic information
00:00:16
during the application's execution.
00:00:20
In power apps,
00:00:20
there are 3 types of variables,
00:00:22
global variables,
00:00:24
local variables,
00:00:25
and collections.
00:00:27
To better understand their use,
00:00:29
imagine that each type of variable is a
00:00:32
different room in your app creation workshop,
00:00:34
each playing a specific and unique role in enriching your developments.
00:00:40
To illustrate the use of a global variable,
00:00:43
start by inserting a button into your application.
00:00:47
In the on select property of this button,
00:00:50
write the following formula.
00:00:54
This formula assigns the value one to the global variable named countervalue.
00:00:59
In the French version of Power Apps,
00:01:00
a semicolon is used to separate parameters,
00:01:04
unlike the English version,
00:01:05
which uses a comma.
00:01:07
Next,
00:01:07
insert a text label into the application.
00:01:11
And in its text property indicate counter value.
00:01:16
To test this configuration,
00:01:17
run the application and click the button.
00:01:21
You will then see the number one displayed in the label.
00:01:24
It is also worth noting that a variable can contain different types of values,
00:01:29
such as numbers or text,
00:01:30
which provides great flexibility during app development.
00:01:35
To illustrate the use of a local variable,
00:01:37
duplicate the previous button.
00:01:40
In the on select property of the new button,
00:01:43
enter the following formula.
00:01:46
This formula creates or updates the local variable named user first name
00:01:50
with the value John.
00:01:52
Unlike global variables,
00:01:54
local variables are limited to the current screen
00:01:57
and are particularly useful for managing states
00:02:00
or temporary values in a restricted context,
00:02:03
such as the screen where it was created.
00:02:07
Collections are variables that allow you to store data sets in a table format.
00:02:11
To begin in the on select property of the button,
00:02:14
write the following formula.
00:02:18
This formula adds a record to the collection named
00:02:20
employee collection with the values Henry and 45.
00:02:25
To test your collection,
00:02:26
start by inserting a gallery,
00:02:28
for example,
00:02:29
a vertical gallery in your application.
00:02:33
Then change the layout of the gallery to display two text fields,
00:02:37
such as one for the name
00:02:38
and another for the age.
00:02:41
Select the gallery and in the item's property,
00:02:44
enter the name of the collection you created earlier.
00:02:47
Employee collection in our example.
00:02:50
This is the variable we populated
00:02:52
using the collect function.
00:02:55
Once the gallery is connected to your collection,
00:02:57
you need to specify what data to display in each text field inside the gallery.
00:03:02
To do this,
00:03:03
use the expression this item.name to display the name,
00:03:08
and this item.age to display the age.
00:03:11
In Power Apps,
00:03:12
this item refers to the current item from the data source linked to the gallery.
00:03:17
Here,
00:03:17
employee collection.
00:03:19
Each row displayed in the gallery corresponds
00:03:21
to a record from employee collection.
00:03:24
This item provides direct access to the fields of this record,
00:03:28
such as name,
00:03:29
age,
00:03:29
or any other property
00:03:31
defined in your collection.
00:03:33
Finally,
00:03:33
run your application in preview mode and click
00:03:36
the button that adds data to your collection.
00:03:39
You will then see the information automatically displayed
00:03:42
with each item in the collection filling a row in the gallery.
00:03:46
Note that if you click this button multiple times,
00:03:49
items will be duplicated in the collection.
00:03:52
To prevent this duplication,
00:03:54
use the clear collect formula instead of collect.
00:03:57
This formula clears the collection before inserting the new record,
00:04:01
ensuring an updated data set.
00:04:04
Use collect when you want to accumulate records over time,
00:04:08
and clear collect when you need to reset the collection with each action.
00:04:13
It is also possible to add multiple items to a collection by combining records.
00:04:17
For example,
00:04:18
using this formula allows you to add 2
00:04:21
records to the collection in a single operation.

No elements match your search in this video....
Do another search or back to content !

 

Mandarine AI: WHAT YOU SHOULD KNOW

Reminder

Show