Using Collections

Usually it is necessary to store the data in temporary storage while calculation or processing. Then, the processed data is transmitted to the data source by saving permanently as ultimate data. Temporary records are stored in the variable tables called Collection. In this method, the data is calculated, processed and quickly written to the cache memory on the app screen only.

These tables are created virtually. Tables and columns can be named however wanted. Columns’ data types are automatically shaped based on the data they contain or the data source that will be saved tı later.

The Collect formula is used to create the collection tables. It is written as (table name ; { columns}) like below:

{ column1:   textbox1.Text;
column2:   textbox2.Text;
column3:   textbox3.Text    } )

For example, you can write this formula into the OnSelect property of the SAVE button of OnTimerStart/OnTimerEnd property of the timer.

Using Collections

The personnel records will be written on collection in the screen of the image you see. 4 textboxes, 4 labels, button and gallery items have been used in this screen.

Item names are frequently used in formulas. So, the functional items in the screen should be named based on what they do or the data they contain.

Textbox names are: txt_name, txt_surname, txt_mail, txt_department

The formula below has been written into the OnSelect property of the SAVE button for the data entered in textboxes to be written to the Collection table.

*Table and columns can be named as desired.

Collect( Personnel;
P_name:    txt_name.Text;
P_surname:    txt_surname.Text;
P_mail:    txt_mail.Text;
P_department:    txt_department.Text   } )

When you click the save button, the data will be transmitted to the collection in seconds.

How to View Collection Data

All collections and their contents can be analyzed on a single screen with the Collections button in the View tab.

Click the gallery item to view the data in lists and choose the related Collection in the screen that opens up.

For the older versions, you can choose in the Data Source field in the Properties Window. Or you can execute the same action why writing the table name into the Items property of the gallery through formula bar.

To reset the textboxes after clicking the save button, the Reset() function is used.

*;; is used in actions that need to be executed successively.

Collect( Personnel;
P_name:    txt_name.Text;
P_surname:    txt_surname.Text;
P_mail:    txt_mail.Text;
P_department:    txt_department.Text   } );;



Conditional Formatting Lists

You can design lists with a condition with the If Formula in the gallery. It is possible to control a lot of features of the objects like color, look, size and place with these conditions. You can authorize based on person/department , hide/show buttons on the screen and highlight status in tracking processes.

Designing Lists with a Condition

In this example, items indicated with colors depending on the information they contain. While all the items of the “Education” department are indicated with purple, the Sales department is displayed with Grey.

ThisItem word is used to individually evaluate each item in the gallery. This way, it is possible to access the data of a certain row among the items.

While registering, people enter their names and surnames separately. And the & concatenation operator is used to write the name and surname next to each other.

ThisItem.P_name & ” ” & ThisItem.P_surname

Adding a Condition

An empty Label is added to the gallery and placed on the left of the gallery to highlight the items.

If(ThisItem.P_departman=”Education”;Purple; Gray) is written into the Fill property of the Label.

With this syntax, each row in the gallery will be evaluated one by one and the department info will be checked. If the department is Education, it will be displayed with Purple. If it is another department, it will be displayed with Grey.

As well as you can write the color as Purple, Red, Blue; you can also write it through the RGB codes.

When you want to use a special color code, the RGBA() function is used.
This function is written as RGBA(255; 255 ; 255 ; 1) as well. The last parameter of the formula gets a value between 0 and 1 and affects the transparency of the color.

You can click here for the other Power Apps articles.

You can click here for the details of the use of the If function.