Power Apps Sequence Function [With Various Examples]

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:

  1. Power Apps Sequence Numbers and Letters
  2. Power Apps Sequence Dates
  3. 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,

  1. Records = This is required. It specifies the number of records to create. Also, it must be in the range of 0 to 50,000.
  2. Start = It is optional. This defines the starting number for the sequence. The default is 1.
  3. Step = It is optional. It specifies the incremental value. The step can be negative to count down from the Start. The default is 1.
See also  Dataverse Primary Name Column Autonumber

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.

FormulaDescriptionOutput
Sequence(5)Creates a 5 record table starting at the default 1 and incrementing by the default 1.Power Apps Sequence Function
Sequence( 5, 35)Creates a 5-record table starting at 35 and incrementing by the default 1.Sequence Function in Power Apps
Sequence(10, 0, 5)It specifies 10 is the number of records, 0 is the starting number, and 5 is the incremental value.PowerApps Sequence Function
Sequence(7, 10, -1)Generates a 7-record table with numbers from 10-to-4.Sequence Function in PowerApps
Sequence(5, -50, 0.5 )Creates a 5-record table starting at -50 and incrementing by 0.5.Power Apps Sequence Function Examples
Sequence(0.5)Creates an empty table as the count rounds down to 0.PowerApps Sequence Function Examples
ForAll(Sequence(10), Rand())Generates a 10-record table of random numbers.Power Apps Sequence Random Number
Concat(Sequence(10), Text(Value) & ” ” )Creates a string of numbers from 1 to 10. [Here, I applied the formula in a Text label control]Sequence function Power Apps
ForAll(Sequence(26, 65, 1), Char(Value))Generates a table of all letters A-to-Z.Power Apps sequence function example

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.

FormulaDescriptionOutput
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.
Power Apps Sequence Dates
ForAll(Sequence(7), Date(2023, 1, Value))Generates a table of the next 7 days starting 2023/01/01.Power Apps Sequence Date
ForAll(Sequence(7, 6, 7), Date(2023, 8, Value))Creates a table of all of the days in August for the year 2023.Sequence Dates in Power Apps
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.powerapps sequence dates
ForAll(Sequence(12), Date(2023, Value, 1))A calendar showing each month’s first day in 2023.Sequence date in Power Apps
ForAll(Sequence(12), DateAdd(Date(2023, Value, 1), 1,TimeUnit.Months) – 1)A calendar showing each month’s last day in 2023.Power Apps Sequence Date Examples

The above examples are related to Power Apps Sequence Dates.

See also  Getting your data Power Apps Error

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.”
Power Apps Sequence 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,

  1. 7 = Specify the total number of records that you want to generate
  2. colRandomNumbers = Collection name
power apps add sequence to collection
  • Next, select the gallery and set its Items property as:
Items = colRandomNumbers

Refer to the image below.

PowerApps Sequence Collection
  • 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,
PowerApps Sequence Examples
  • 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

Sequence Examples Power Apps
  • 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:

See also  Power Apps Filter SharePoint List [25+ 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:

  1. Power Apps Sequence Numbers and Letters
  2. How to use Power Apps Sequence Dates
  3. Working with Power Apps Sequence Collection
>