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

Drop down list showing few months from now

Hi guys, 

 

My app is to ask people fill in the report daily or monthly, and data has been connected  to sql server.

When someone choose the service name, it will automatically show this is a daily or monthly report.

My problem is that if this a monthly report, how can I display a drop down menu showing just past three months from now to let people choose one.

Plus, if this a daily report, how can I display a drop down menu showing only past two weeks date from now.

Please help me. Thank you very much.

 

 
 

Screenshot 2020-12-15 214140.jpg

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

No worries! More than half the challenge in developing apps is deciding/designing them.

Here's updated code for all the days:

With(
    {
        varToday: Today(),
        varWeeks: 4 * 7
    },
    ForAll(
        Sequence(varWeeks),
        {
            tblDate: Text(
                DateAdd(
                    varToday,
                    (ThisRecord.Value - varWeeks + 7),
                    Days
                ),
                DateTimeFormat.ShortDate
            )
        }
    )
)

 

Here's updated code for a 5-month range, with 2 months before this month, and 2 after.

With(
    {
        varStartDate: DateAdd(
            Today(),
            -3,
            Months
        ),
        varMonths: 5
    },
    ForAll(
        Sequence(varMonths),
        {
            tblDate: Text(
                DateAdd(
                    varStartDate,
                    ThisRecord.Value,
                    Months
                ),
                "[$-en-US]mmm yyyy"
            )
        }
    )
)

 

View solution in original post

5 REPLIES 5
GarethPrisk
Resident Rockstar
Resident Rockstar

Something like this will give you three rows (this week, and two weeks prior). You can tweak the Text formatting, to adjust how it shows up.

With(
    {
        varToday: Today(),
        varWeeks: 3
    },
    ForAll(
        Sequence(varWeeks),
        {
            tblDate: Text(
                DateAdd(
                    varToday,
                    (ThisRecord.Value - varWeeks) * 7,
                    Days
                ),
                DateTimeFormat.ShortDate
            )
        }
    )
)

 

Something like this will give you the last three months, including the current.

With(
    {
        varToday: Today(),
        varMonths: 3
    },
    ForAll(
        Sequence(varMonths),
        {
            tblDate: Text(
                DateAdd(
                    varToday,
                    (ThisRecord.Value - varMonths),
                    Months
                ),
                "mmm yyyy"
            )
        }
    )
)
Anonymous
Not applicable

Thank you so so so much for your reply. It works! The only problem is that I'd like to show all the dates within three weeks (two past weeks from now and one future week ) not just three days. Sorry for my unclear explanation before.

Also, what if I want four months which are past two months from now, now and one month later. 

 

Again, I really appreciate what you did because I am quite a new Power app learner.

No worries! More than half the challenge in developing apps is deciding/designing them.

Here's updated code for all the days:

With(
    {
        varToday: Today(),
        varWeeks: 4 * 7
    },
    ForAll(
        Sequence(varWeeks),
        {
            tblDate: Text(
                DateAdd(
                    varToday,
                    (ThisRecord.Value - varWeeks + 7),
                    Days
                ),
                DateTimeFormat.ShortDate
            )
        }
    )
)

 

Here's updated code for a 5-month range, with 2 months before this month, and 2 after.

With(
    {
        varStartDate: DateAdd(
            Today(),
            -3,
            Months
        ),
        varMonths: 5
    },
    ForAll(
        Sequence(varMonths),
        {
            tblDate: Text(
                DateAdd(
                    varStartDate,
                    ThisRecord.Value,
                    Months
                ),
                "[$-en-US]mmm yyyy"
            )
        }
    )
)

 

Anonymous
Not applicable

It really helps. Thank you so much.

Anonymous
Not applicable

Just a quick question, how can I set a Blank item in that dropdown as Default  since sometimes people just leave the first date showing in the menu and forget to select one.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,369)