No Ads, No Fluff, Just Power Apps Stuff

# Power Apps SEQUENCE Function

Yesterday the SEQUENCE function was announced on Microsoft’s official Power Apps blog. I thought I’d provide some details on how to use SEQUENCE since the Power Apps documentation does not yet include a page for it.

Description

The SEQUENCE function creates a range of numbers as a single column table. This could be a continuous range like the numbers from 1-to-100 or non-continuous range such as [2, 4, 6, 8 10]. Ranges of dates and letters can be produced as well.

Syntax

Sequence(records, start, step)

• records – Required. Quantity of numbers in the sequence.
• start – Optional. Starting number of the sequence. Default is 1.
• step – Optional. Incremental value. Default is 1

Examples

Numbers

A table with all numbers from 1-to-10

Sequence(10)

A table with all multiples of 10 from 0-to-100

Sequence(10, 0, 10)

A table with numbers from 10-to-1

Sequence(10, 10, -1)

Letters

A table of all letters A-to-Z

ForAll(Sequence(26, 65, 1), Char(Value))

Dates

A table of the next 7 days starting 2020-01-01

ForAll(Sequence(7), Date(2020, 1, Value))

A table of the next 5 Saturdays starts 2020-01-04

ForAll(Sequence(5, 4, 7), Date(2020, 1, Value))

A table of the first day of each month in the year 2020

ForAll(Sequence(12), Date(2020, Value, 1))

A table of the last day of each month in the year 2020

ForAll(Sequence(12), DateAdd(Date(2020, Value, 1), 1, Months) - 1)

A table of all of the days in the month of January for the year 2020

ForAll(Sequence(Day(DateAdd(Date(2020, 1, 1), 1, Months)-1), 1, 1), Date(2020, 1, Value))

Random

A random number between 1-and-100

First(Shuffle(Sequence(1, 100, 1))).Value

### Matthew Devaney

Subscribe
Notify of

Inline Feedbacks
Vanessa
2 years ago

Hi Matthew,

I got the validation for duplicate date range to work on the calendar app that I’m building. I tested the sequence function separately to create recurring meetings and it worked but when I combined it together, it does create recurring meeting but it stopped validating for conflict date range.
My SharePoint list has StartDateTime and EndDateTime column. I set the Start and End as below and from there set the conflict as varRecord and if it’s empty it should patch with the sequence function. If it’s not blank, then I should get notification error.

Set(Start, start.SelectedDate + stime.Selected.Value);
Set(End, end.SelectedDate + etime.Selected.Value);
Set(varRecord, LookUp(‘Anchorage Working Calendar’, StartDateTime <= Start && EndDateTime > Start || StartDateTime > Start && EndDateTime <= End || StartDateTime < Start && EndDateTime > End));

If(IsBlank(varRecord.ID),
ForAll(Sequence(Value(‘days/weeks’.Text)) As recurringmeetings,Patch(‘Anchorage Working Calendar’, {‘Client Name’: Client.Text, StartDateTime: start.SelectedDate+(recurringmeetings[@Value]*7)+stime.Selected.Value, EndDateTime:end.SelectedDate+(recurringmeetings[@Value]*7)+etime.Selected.Value})),

Nidheesh S Shanbhag
1 year ago

Hi,
i have to create a dropdown list, with dates 1st-13th,11th-23rd,21st-03rd of all the months in a year,for eg:- jan month should have dates as 1-01-year to 13-01-year, 11-01-year to 23-01-year,21-01-year to 31-01-year, same has to be for all the months of a year, can you please guide me in this sir.

Nidheesh
1 year ago

Yes sir it is one of my requirement for time sheet, like from 1st-13th is the locking period for submission of the timesheet, user can apply time sheet only on the above dates,so is their any way to achieve this dates in the drop-down sir?

Nidheesh
1 year ago

Sure sir,
01-01-2022 to 10-01-2022
11-01-2022 to 21-01-2022
22-01-2022 to 30/31-01-2022

01-02-2022 to 10-02-2022
11-02-2022 to 21-02-2022
22-02-2022 to 28/29-02-2022

01-03-2022 to 10-03-2022
11-03-2022 to 21-03-2022
22-03-2022 to 30/31-03-2022

Sir requirement is that user can submit time sheet of 1st to 10th on 13th of the month,likewise 11th to 21st on 23rd of the month and
22nd to 30/31 on 1st of the month so 13th,23rd and 1st are the days where he can submit the time sheet sir
Can you please guide me on this requirement sir

Nidheesh
1 year ago

Sir can you please guide me on how to achieve the above requirement,it would be of great help

Mhk
9 months ago

Hey, Can we generate auto serial no.s in Data Table?

Doug
4 months ago

How do you use sequence but format it to have leading zeros? I want to have the numbers formatted to 5 digits (i.e. 00003, 00004, 00005, etc.)

Doug
4 months ago

Thanks Matthew. I tried that and it actually added the zeros to the end(?) I’ll try it again in the event I typed something wrong but I ended up having a ForAll loop spin through the collection and was able to use the Text formatting there.