cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Set calendar or date picker with recurring dates

I have searched all over for answers and I hope this forum can provide them. I've created meeting calculator for people to use when they are trying to present a topic to committee. One committee is on the 1st and 3rd Tuesday if the month, another is on the 2nd Tuesday of the month, another is every Monday, and the last one is every 2nd and 4th Tuesday of the month. The topic has to be presented at one meeting, if approved there, then it moves on to the next so on and so forth.

Having all these deadlines really confuses people so I am trying to create a calculator to help plan out their schedule and the deadlines for those memos. 

I've got the text boxes (in View mode only) set to calculate the deadline date from the initial date picker (there is one for each committee)

Here's what I'd like to do:

  1. For the initial date pickers: Is there a way that I can highlight the meeting frequency on that date picker. For example: Committee A is on the 1st & 3 Tuesday of the month, so those are highlighted on the date picker?
  2. Is it possible to have the date picker for Committee A determine the dates for the other Committees in chronological order?
  3. If this isn't possible with a date picker, is there another way? I saw an instruction video on how to do it with a text box.

I'm mostly interested in being able to write the code for the "1st & 3rd Tuesday of the month".

I am solely using the functions of PowerApps, there is no datasource like SharePoint. 

Any and all help is appreciated.

11 REPLIES 11

I am also wanting to know how to add a recurring date selector.

WiZey
Super User
Super User

Hello @rosssimkins2013 ,

 

I tried this formulae based on Power App's basic calendar screen:

 

If(
    Or(
        DateAdd(
            _firstDayInView;
            ThisItem.Value
        ) = DateAdd(
            _firstDayOfMonth;
            3 - Weekday(_firstDayOfMonth) + If(
                Weekday(_firstDayOfMonth) > 3;
                7
            );
            Days
        );
        DateAdd(
            _firstDayInView;
            ThisItem.Value
        ) = DateAdd(
            _firstDayOfMonth;
            3 - Weekday(_firstDayOfMonth) + If(
                Weekday(_firstDayOfMonth) > 3;
                7
            ) + 14;
            Days
        )
    );
    RGBA(
        100;
        100;
        200;
        80%
    );
    RGBA(
        0;
        0;
        0;
        0
    )
)

 

And this is the result:

 

image.png

 

It is effectively highlighting the first and third tuesday of the current month. Is this what you were looking for?

 

Also, could you clarify a bit more your second point ? How do you expect a calendar to show events in a chronological order, when it is already set in a chronological order? 

rosssimkins2013_0-1658311479557.png

So I have this so users can book a room and wanted the ability to use the drop down to make the booking every day, week, month or year. Then the until date is so it knows when they want to make the recurring booking till. For example every Tuesday from now till the end of the year. Thank you in advance.

WiZey
Super User
Super User

I've tried some formulae to calculate the repeat on days and weeks.

 

 

Clear(cltReservationDates);;
Switch(
    Dropdown1.SelectedText.Value;
    "Day";
    With(
        {
            NumberOfDays: DateDiff(
                _dateSelected;
                Self.SelectedDate
            )
        };
        Collect(
            cltReservationDates;
            ForAll(
                Sequence(NumberOfDays);
                {
                    ReservationDate: DateAdd(
                        _dateSelected;
                        Value;
                        Days
                    )
                }
            )
        )
    );
    "Week";
    With(
        {
            NumberOfDays: Trunc(
                DateDiff(
                    _dateSelected;
                    Self.SelectedDate
                ) / 7
            )
        };
        Collect(
            cltReservationDates;
            ForAll(
                Sequence(NumberOfDays);
                {
                    ReservationDate: DateAdd(
                        _dateSelected;
                        Value * 7;
                        Days
                    )
                }
            )
        )
    )
);;
//Remove week-end days from collection
RemoveIf(
    cltReservationDates;
    Weekday(ReservationDate) in [
        1;
        7
    ]
);;

 

 

This can create a collection of all days between a from date and a to date. 

 

"Days" return all days while "Week" return only the corresponding week day.

 

The "RemoveIf()" removes week-end days, but you can delete it if you want to keep saturday and sunday.

 

I'm still hitting my forehead to come up with the "Month" and the "Year" part, so hopefully someone already made something similar somewhere else.

 

Can you try this sample and see how it goes?

 

Edit:

 

I've completed the sample with month and year repetition. The formulae looks like this:

 

//Clear the collection of reservation dates
Clear(cltReservationDates);;

//Compute the date using the method for Day/Week/Month/Year repetition
Switch(
    Dropdown1.SelectedText.Value;
    "Day";
    //Daily repetition
    //NumberOfDays: day difference between FromDate and ToDate
    With(
        {
            NumberOfDays: DateDiff(
                _dateSelected;
                Self.SelectedDate
            )
        };
        //Add an iteration to create a list of dates between FromDate and ToDate
        Collect(
            cltReservationDates;
            ForAll(
                Sequence(NumberOfDays);
                {
                    ReservationDate: DateAdd(
                        _dateSelected;
                        Value;
                        Days
                    )
                }
            )
        )
    );
    //Weekly repetition
    //NumberOfDays: week difference between FromDate and ToDate
    "Week";
    With(
        {
            NumberOfDays: Trunc(
                DateDiff(
                    _dateSelected;
                    Self.SelectedDate
                ) / 7
            )
        };
        //Add an iteration to create a list of dates between FromDate and ToDate
        //The iteration is multiplied by 7 to jump from week to week.
        Collect(
            cltReservationDates;
            ForAll(
                Sequence(NumberOfDays);
                {
                    ReservationDate: DateAdd(
                        _dateSelected;
                        Value * 7;
                        Days
                    )
                }
            )
        )
    );
    //Monthly repetition
    //NumberOfDays:month difference between FromDate and ToDate
    "Month";
    With(
        {
            NumberOfDays: Trunc(
                DateDiff(
                    _dateSelected;
                    Self.SelectedDate
                ) / 7 / 4
            )
        };
        ForAll(
            Sequence(NumberOfDays);
            //ForwardDate:next iteration
            //NthWeekDayOfReservation:determine if week day is the first, second or third 
            //FirstDayOfForwardDate:first day of the next iteration
            With(
                {
                    ForwardDate: DateAdd(
                        _dateSelected;
                        Value;
                        Months
                    )
                };
                With(
                    {
                        NthWeekDayOfReservation: Trunc(
                            Day(
                                DateAdd(
                                    DateAdd(
                                        _dateSelected;
                                        1;
                                        Months
                                    );
                                    -1;
                                    Days
                                )
                            ) / 7
                        );
                        FirstDayOfForwardDate: Date(
                            Year(ForwardDate);
                            Month(ForwardDate);
                            1
                        )
                    };
                    //The calculation is done so we always get the nth week day of each iteration
                    Collect(
                        cltReservationDates;
                        {
                            ReservationDate: Date(
                                Year(ForwardDate);
                                Month(ForwardDate);
                                Weekday(_dateSelected) - Weekday(FirstDayOfForwardDate) + If(
                                    Weekday(FirstDayOfForwardDate) > Weekday(_dateSelected);
                                    7
                                ) + (7 * NthWeekDayOfReservation) + 1
                            )
                        }
                    )
                )
            )
        )
    );
    "Year";
    //Yearly repetition
    //NumberOfDays:year difference between FromDate and ToDate
    With(
        {
            NumberOfDays: Trunc(
                DateDiff(
                    _dateSelected;
                    Self.SelectedDate
                ) / 7 / 4 / 12
            )
        };
        ForAll(
            Sequence(NumberOfDays);
            //ForwardDate:next iteration
            //NthWeekDayOfReservation:determine if week day is the first, second or third 
            //FirstDayOfForwardDate:first day of the next iteration
            With(
                {
                    ForwardDate: DateAdd(
                        _dateSelected;
                        Value;
                        Years
                    )
                };
                With(
                    {
                        NthWeekDayOfReservation: Trunc(
                            Day(
                                DateAdd(
                                    DateAdd(
                                        _dateSelected;
                                        1;
                                        Months
                                    );
                                    -1;
                                    Days
                                )
                            ) / 7
                        );
                        FirstDayOfForwardDate: Date(
                            Year(
                                DateAdd(
                                    _dateSelected;
                                    Value;
                                    Years
                                )
                            );
                            Month(
                                DateAdd(
                                    _dateSelected;
                                    Value;
                                    Years
                                )
                            );
                            1
                        )
                    };
                    //The calculation is done so we always get the nth week day of each iteration
                    Collect(
                        cltReservationDates;
                        {
                            ReservationDate: Date(
                                Year(ForwardDate);
                                Month(ForwardDate);
                                Weekday(_dateSelected) - Weekday(FirstDayOfForwardDate) + If(
                                    Weekday(FirstDayOfForwardDate) > Weekday(_dateSelected);
                                    7
                                ) + (7 * NthWeekDayOfReservation) + 1
                            )
                        }
                    )
                )
            )
        )
    )
);;
//Remove week-end days from collection
RemoveIf(
    cltReservationDates;
    Weekday(ReservationDate) in [
        1;
        7
    ]
);;

 

This formulae should give you a list of dates between FromDate and ToDate, following the repetition on Day/Week/Month/Year.

 

Month and Year repetition is made to always give you the nth week day of the month. For example, if you selected the second Tuesday of the month, it will give you a list of all the second Tuesday of each months between FromDate and ToDate.

I tried other approaches, but I always ended up either skipping a month because the date ended up on a week-end or having two dates in the same month, so I believe this solution is the more optimal of the lot.

 

Can you try using the new formulae and see how it goes?

rosssimkins2013_0-1658387083737.png

Thank you so much for all your work. It is so good of you. I have included a screen shot of the current formulae I have on the 'Continue' button. Is this where I would need to paste the formulae you have provided? The drop down with Day, Week, Month, Year in is called DDFrequency. Sorry to sound thick but I am just starting out my Powerapps journey. Thank you in advance.

WiZey
Super User
Super User

I have put my code in the "OnChange()" of a datepicker, so everytime I picked a new date it would compute a new list of dates. It was the earliest place where both "FromDate" and "ToDate" are defined.

 

I see you're defining "startTime" and "endTime" in your "OnSelect()" of the button. I'd say paste my formulae between the "Set()" and the "If()" and don't forget to change the variables' name I've used to adapt to your app's specifics (because "_dateSelected" is specific to my app).

 

You could even add another popup for when the "cltReservationDates" is empty to warn the user his selection doesn't bring up any result.

Will try this now. Thank you.

rosssimkins2013_0-1658479320535.png

I have added the code into where you said but am still getting a number of errors. Not sure what I am doing wrong now. Sorry and thank you for your help.

WiZey
Super User
Super User

Looks like it's mostly because I use semicolon as separator while you use comma. It's a difference of syntax between our country which should be easily fixable.

 

Can you try replacing all ";" with "," and see how it goes?

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (772)