web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / "The first argume...
Power Apps
Answered

"The first argument to Sequence must be between 0 and 50,000."

(0) ShareShare
ReportReport
Posted on by 1,257 Super User 2024 Season 1

Ok I've seen two other posts on this but unfortunately I can't relate them to mine. I think it's the same issue but I can't come up with the solution

 

This is the syntax I have in a text box in a form

 

With(
 {
 // generate a one-column table of all dates between start date & end date
 gblDateRange: ForAll(
 Sequence(dpEnd.SelectedDate - dpStart.SelectedDate + 1),
 dpStart.SelectedDate + Value - 1
 )
 },
 If(
 And(
 IsBlank(dpStart.SelectedDate),
 IsBlank(dpEnd.SelectedDate)
 ),
 // show nothing if any date pickers are blank
 0,
 // include only dates Monday to Friday
 If(
 conHalf,
 CountIf(
 gblDateRange,
 Weekday(Value) in [2, 3, 4, 5, 6]
 ) - 0.5,
 CountIf(
 gblDateRange,
 Weekday(Value) in [2, 3, 4, 5, 6]
 )
 )
 )
)

 

 when I submit the form I get the above error. It doesn't prevent the submitting of the data.  From what I have read it seems to have something to do with where I'm subtracting the  0.5  and getting a negative value?  Not sure how to resolve it..

 

Any ideas?

 

Thanks 

Categories:
  • Verified answer
    realwillwright Profile Picture
    772 Moderator on at

    Hi @vffdd 

     

    I think it is to do with your sequence in the with function, I have updated below. I used Craig Whites blog for inspiration 10 Easy Ways to use the Power Apps Sequence Function - Platforms of Power

     

    With(
     {
     // generate a one-column table of all dates between start date & end date
     gblDateRange: ForAll(Sequence(DateDiff(dpStart.SelectedDate, dpEnd.SelectedDate, TimeUnit.Days) + 1,0), Today()+Value)
     },
     If(
     And(
     IsBlank(dpStart.SelectedDate),
     IsBlank(dpEnd.SelectedDate)
     ),
     // show nothing if any date pickers are blank
     0,
     // include only dates Monday to Friday
     If(
     conHalf,
     CountIf(
     gblDateRange,
     Weekday(Value) in [2, 3, 4, 5, 6]
     ) - 0.5,
     CountIf(
     gblDateRange,
     Weekday(Value) in [2, 3, 4, 5, 6]
     )
     )
     )
    )


    -------------------------------------------------------------------

    If my reply helped you, please give a 👍
    If it solved your issue, please give a 👍 & accept it as the Solution to help other community members find it.

  • vffdd Profile Picture
    1,257 Super User 2024 Season 1 on at

    Thank you @realwillwright  that sorted it

  • vffdd Profile Picture
    1,257 Super User 2024 Season 1 on at

    Hi @realwillwright  I'm back again I'm afraid because I have just noticed that while it solves the sequence issue it does not actually count only Monday to Friday as it did previously? It's now counting all days between the dates.

     

    and edited to add that sequence error has returned?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard