cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
xr19970428
Frequent Visitor

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
Super User II
Super User II

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"
            )
        }
    )
)

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"
            )
        }
    )
)

 

View solution in original post

It really helps. Thank you so much.

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (19,432)