Latest Posts

PowerApps Generate a table of sequential numbers


The Sequence function in PowerApps generates a table of sequential numbers. This function can be useful for creating a list of numbers, iterating over a range of values, or generating indices for other operations.

PowerApps – Sequence() function Syntax

Sequence(Count [, Start [, Step]])

  • Count: The number of sequential numbers to generate.
  • Start: (Optional) The starting number of the sequence. The default value is 1.
  • Step: (Optional) The step value between each number in the sequence. The default value is 1.

Notes:

  • Zero or Negative Count: If Count is zero or negative, the function will return an empty table.
  • Non-integer Step: The Step value can be non-integer, but ensure it makes sense in your context to avoid unexpected results.

PowerApps – Sequence of 1 to 10 numbers

Generate a sequence of 10 numbers starting from 1:

Sequence(10)

This returns a table: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].

PowerApps – Sequence of 5 numbers from 100

Generate a sequence of 5 numbers starting from 100:

Sequence(5, 100)

 

This returns a table: [100, 101, 102, 103, 104].

PowerApps –Sequence of 5 numbers skipping 1 number

Generate a sequence of 5 numbers starting from 1 with a step value of 2:

Sequence(5, 1, 2)

This returns a table: [1, 3, 5, 7, 9].

PowerApps –Sequence of 5 numbers  from 10 in reverse order

Generate a sequence of 5 numbers starting from 10 with a step value of -1:

Sequence(5, 10, -1)

This returns a table: [10, 9, 8, 7, 6].

If you have a gallery and you want to generate index numbers for each item:

Sequence(CountRows(Gallery1.AllItems))

This creates a sequence of numbers equal to the number of items in the gallery.

PowerApps - Create Pagination Controls

For creating pagination in a gallery, you can generate page numbers dynamically:

Sequence(TotalPages)

Where TotalPages is a variable representing the total number of pages.

PowerApps – Perform Repeating Actions using Sequence() function

To perform an action multiple times, you can use Sequence in combination with the ForAll function. For example, to create a table with repeated values:

ForAll(Sequence(10), { Value: "Item " & Text(Value) })

This creates a table with 10 items, each labeled "Item 1", "Item 2", ..., "Item 10".


We value your Feedback:

Page URL:

Name:

Email:


Suggestion:

© 2024 Code SharePoint