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

Community site session details

Session Id :
Power Apps - Building Power Apps
Suggested answer

Exclude weekends and Tuesdays from start date on Date Picker

(0) ShareShare
ReportReport
Posted on by 4
Current code has a start date based on the answer to a previous dropdown.
 
If they select VALUE1 - Start date is 5 business days from today.
If they select VALUE2 or VALUE 3 - Start date is 7 business days from today.
 
The only problem is that it doesn't exclude non-business days (weekends and Tuesdays).
 
If(DataCardValue24.Selected.Value = "VALUE1", DateAdd(Today(), 5, TimeUnit.Days), If(DataCardValue24.Selected.Value = "VALUE2" || DataCardValue24.Selected.Value = "VALUE3", DateAdd(Today(), 7, TimeUnit.Days), Blank()))
I have the same question (0)
  • Suggested answer
    WarrenBelz Profile Picture
    151,978 Most Valuable Professional on at
    Exclude weekends and Tuesdays from start date on Date Picker
    Try this
    With(
       {
          _Days: Switch(
             DataCardValue24.Selected.Value,
             "VALUE1",
             5,
             "VALUE2",
             7,
             "VALUE3",
             7
          )
       },
       Last(
          FirstN(
             Filter(
                ForAll(
                   Sequence(_Days + 3),
                   With(
                      {_Next: Today() + Value},
                      If(
                         Weekday(_Next) in [2, 4, 5, 6],
                         _Next,
                         Blank()
                      )
                   )
                ),
                !IsBlank(Value)
             ),
             _Days
          )
       ).Value
    )
     
    Please Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like
    Visit my blog
    Practical Power Apps    LinkedIn  
     
  • Suggested answer
    DeveloperAK Profile Picture
    13 on at
    Exclude weekends and Tuesdays from start date on Date Picker
    Hello @RK-20112128-0

    If you want to set a start date based on a dropdown selection, excluding weekends and Tuesdays, you can’t just use DateAdd() directly with a fixed number of days. Instead, you need to loop through the days and skip the ones you don’t want.

    Please try below solution: 

    Here’s an approach using ForAll() and Sequence to calculate the date dynamically:

    With(
        { DaysToAdd: Switch(
            DataCardValue24.Selected.Value,
            "VALUE1", 5,
            "VALUE2", 7,
            "VALUE3", 7,
            0
          )
        },
        If(
            DaysToAdd = 0,
            Blank(),
            Last(
                FirstN(
                    Filter(
                        ForAll(
                            Sequence(50) As _obj, // enough days to cover business days
                            { ResultDate: DateAdd(Today(), _obj.Value , TimeUnit.Days) }
                        ),
                        Weekday(ResultDate) <> 1 &&  // Sunday
                        Weekday(ResultDate) <> 3 &&  // Tuesday
                        Weekday(ResultDate) <> 7     // Saturday
                    ),
                    DaysToAdd
                ).ResultDate
            )
        )
    ).ResultDate
    

    This ensures your start date always skips weekends and Tuesdays, regardless of the dropdown choice.

    📩 Need more help? Mention @DeveloperAK anytime!
    ✔️ Don’t forget to Accept as Solution if this guidance worked for you.
    💛 Your Like motivates me to keep helping.
     

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

Coming soon: forum hierarchy changes

In our never-ending quest to improve we are simplifying the forum hierarchy…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 664 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 373 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 246 Super User 2025 Season 2

Last 30 days Overall leaderboard