This Power Apps tutorial will guide you on the Sequence function in Power Apps, like what is this Power Apps Sequence Function, its syntax, and how we use it.
Also, we will see various examples based on the Power Apps Sequence Function like:
- Power Apps Sequence Numbers and Letters
- Power Apps Sequence Dates
- Power Apps Sequence Collection
Check out Power Apps Gallery Control Examples Download [20 Various Real Scenarios]
Power Apps Sequence Function
- Power Apps Sequence function creates a single-column table of numbers in order, like 1, 2, and 3. The column is called Value. This might be a continuous range, like the numbers from 1 to 100, or it could be non-continuous, like [2, 4, 6, 8, 10].
- Additionally, ranges of dates and letters can be generated.
- The number of records to be produced must be between 0 and 50,000, rounded to the nearest whole number. A table that is created with no records is empty.
Power Apps Sequence Function Syntax
The below represents the syntax of the Power Apps Sequence function:
Sequence( Records [, Start [, Step ] ] )
Where,
- Records = This is required. It specifies the number of records to create. Also, it must be in the range of 0 to 50,000.
- Start = It is optional. This defines the starting number for the sequence. The default is 1.
- Step = It is optional. It specifies the incremental value. The step can be negative to count down from the Start. The default is 1.
Power Apps Sequence Function Examples
Let’s work with some examples using the Power Apps Sequence Function.
Power Apps Sequence Numbers and Letters
The table below represents all examples of Power Apps Sequence Numbers and Letters. Below are all the formulas I have used in a Power Apps Gallery Control‘s Items property.
Formula | Description | Output |
---|---|---|
Sequence(5) | Creates a 5 record table starting at the default 1 and incrementing by the default 1. | |
Sequence( 5, 35) | Creates a 5-record table starting at 35 and incrementing by the default 1. | |
Sequence(10, 0, 5) | It specifies 10 is the number of records, 0 is the starting number, and 5 is the incremental value. | |
Sequence(7, 10, -1) | Generates a 7-record table with numbers from 10-to-4. | |
Sequence(5, -50, 0.5 ) | Creates a 5-record table starting at -50 and incrementing by 0.5. | |
Sequence(0.5) | Creates an empty table as the count rounds down to 0. | |
ForAll(Sequence(10), Rand()) | Generates a 10-record table of random numbers. | |
Concat(Sequence(10), Text(Value) & ” ” ) | Creates a string of numbers from 1 to 10. [Here, I applied the formula in a Text label control] | |
ForAll(Sequence(26, 65, 1), Char(Value)) | Generates a table of all letters A-to-Z. |
This is all about examples of Power Apps Sequence Numbers and Letters.
Power Apps Sequence Dates
Now we will explore how to work with Power Apps Sequence Dates using various formulas. Below are all the formulas I have used in a Power Apps Gallery Control’s Items property.
Formula | Description | Output |
---|---|---|
ForAll( Sequence( 10 ), DateAdd( Today(),Value,TimeUnit.Days ) ) | Another way to change the value’s data type and return a new table is to use the ForAll function. In this case, the formula produces a table of the upcoming 10 days. | |
ForAll(Sequence(7), Date(2023, 1, Value)) | Generates a table of the next 7 days starting 2023/01/01. | |
ForAll(Sequence(7, 6, 7), Date(2023, 8, Value)) | Creates a table of all of the days in August for the year 2023. | |
ForAll(Sequence(Day(DateAdd(Date(2023, 8, 1), 1, TimeUnit.Months)-1), 1, 1), Date(2023, 8, Value)) | Creates a table of all of the days in the month of August for the year 2023. | |
ForAll(Sequence(12), Date(2023, Value, 1)) | A calendar showing each month’s first day in 2023. | |
ForAll(Sequence(12), DateAdd(Date(2023, Value, 1), 1,TimeUnit.Months) – 1) | A calendar showing each month’s last day in 2023. |
The above examples are related to Power Apps Sequence Dates.
Power Apps Sequence Collection
This example will discuss how to work with Power Apps Sequence Collection.
- A Power Apps Button control and a Gallery control are seen in the screenshot below. The random numbers are generated in the collection, and their values are displayed in the gallery control when a user hits the “Add Random Number to Collection.”
- To achieve this, select the button control and apply the code below on its OnSelect property as:
OnSelect = ForAll(
Sequence(7),
Collect(
colRandomNumbers,
Rand()
)
)
Where,
- 7 = Specify the total number of records that you want to generate
- colRandomNumbers = Collection name
- Next, select the gallery and set its Items property as:
Items = colRandomNumbers
Refer to the image below.
- Save, Publish, and Preview the app. Click on the button; then the gallery will display all 7 random values.
This is how to work with Power Apps Sequence Collection.
Power Apps Sequence Examples
The gallery will be generated in this example anytime a user enters any number into the text input control.
- Suppose when I entered a number as 3, the gallery automatically incremented with three sections, as shown below,
- To work around this, apply the formula below on the gallery’s Items property:
Items = ForAll(
Sequence(Value(txtEnterNumber.Text)),
Blank()
)
Where,
txtEnterNumber = Text input control name
- Save, Publish, and Preview the app. Enter a number to the text input control; the gallery will increase or decrease according to the user’s input.
This is how we can generate a gallery section automatically using the Power Apps Sequence function.
Moreover, you may like some more Power Apps tutorials:
- How to Create Empty Collection in Power Apps
- Power Apps Collection Distinct Filter [With Different Data Types]
- Power Apps Sort Function [With 19 useful examples]
- PowerApps Search Function + How to use with example
- PowerApps Find Function With Examples
- PowerApps Mod Function
- Power Apps Filter Gallery By Quarter [With Various Scenarios]
- Power Apps Filter Gallery By Year [With Real Examples]
In this Power Apps tutorial, we learned what Power Apps Sequence Function, Power Apps Sequence Function Syntax, and how to use it.
Also, we saw various examples using Power Apps Sequence functions like:
- Power Apps Sequence Numbers and Letters
- How to use Power Apps Sequence Dates
- Working with Power Apps Sequence Collection
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com