cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PowerSäm
Skilled Sharer
Skilled Sharer

Calendar option: Do not count certain days when summing up - Possible?

Hello All,

I am currently building an app that allows you to create leave requests. The user must specify from when to when he is on vacation and this is then automatically converted into days (See images).

 

PowerSm_0-1669129929292.png

 

I have also programmed it to automatically subtract weekends, so to count only Monday to Friday.

But now the company also closes 1-2 times a year. I would like to program the days as well so that when someone selects them, they are not counted as 1 day.

 

How can I do this? Can I say: "If 28.11.2022 is selected, then count it as no day". Is that somehow possible? If yes, how?

 

The code behind the day counter (Inputfield: Anzahl Tage):

PowerSm_1-1669130115306.png

 

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
PowerSäm
Skilled Sharer
Skilled Sharer

Thanks so much for your help, @KeithAtherton. But I found an easier way to solve this

I first created a sharepoint list ("Feiertage") with the column heading "Feiertag".
Then I used the following fromula to exclude the weekend and the holidays:

 

PowerSm_1-1669972773240.png

 

Look! It worked.

I hope I can help others with it. But nevertheless thank you so much for your precious help!

View solution in original post

3 REPLIES 3
KeithAtherton
Responsive Resident
Responsive Resident

Hi @PowerSäm,

 

Yes, this is possible if you create a collection containing the closed/holiday dates then count how many closed/holiday dates fall within the date range:

ClearCollect(
    colHolidays,
    {
        HolidayDate: Date(
            2022,
            11,
            1
        )
    },
    {
        HolidayDate: Date(
            2022,
            12,
            2
        )
    },
    {
        HolidayDate: Date(
            2022,
            12,
            3
        )
    }
);
Set(
    gblDateDiff,
    DateDiff(
        Date(
            2022,
            12,
            1
        ),
        Date(
            2022,
            12,
            10
        ),
        Days
    ) - CountRows(
        Filter(
            colHolidays,
            HolidayDate >= Date(
                2022,
                12,
                1
            ) && HolidayDate <= Date(
                2022,
                12,
                10
            )
        )
    )
);

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

PowerSäm
Skilled Sharer
Skilled Sharer

Thanks so much for your help, @KeithAtherton. But I found an easier way to solve this

I first created a sharepoint list ("Feiertage") with the column heading "Feiertag".
Then I used the following fromula to exclude the weekend and the holidays:

 

PowerSm_1-1669972773240.png

 

Look! It worked.

I hope I can help others with it. But nevertheless thank you so much for your precious help!

KeithAtherton
Responsive Resident
Responsive Resident

My pleasure. Thanks for the update, looks like a good solution!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,944)