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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / New Form - Pre-populat...
Power Apps
Answered

New Form - Pre-populated (Default) Drop-Down Item Based on Today's Date

(0) ShareShare
ReportReport
Posted on by 13

Hello

I am creating a new form and I want one of the drop-down list to be pre-selected with a default value.

 

This list contains dates (in the format of strings), which are Mondays of each week (refer to the attached screenshot). This list is based off a separate SharePoint list (only containing dates), that is looked up by the SharePoint list that is the basis of this form.

 

I want the default value to be the Monday of the following week from today. For example, today is 2020-02-05 (Wednesday). I want the pre-populated default item to be 2020-02-10.

 

I have tried writing the following code in the Default field in the DataCardValue I am interested in, but this doesn't seem to work:

 

 

LookUp(
 
 Choices('Activity List'.Week),
Value=Text(Today() + 7 - Weekday(Today(), MondayZero),"[$-en-AU]yyyy-mm-dd"))

 

 

I would welcome and appreciate any help. Also as this is my first post, just a quick shout out to all users who have been posting and answering questions. This is a very good resource for general queries.

 

Many thanks! 

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,923 on at
    LookUp(
    Choices('Activity List'.Week),
    Text( DateAdd( Now(), 7 ),
    "dd-mm-yyyy" )))
  • southern_cross Profile Picture
    13 on at

    Hi @eka24

     

    Thanks for your reply.

     

    As I understand it, the dateadd function only adds 7 days ahead to whatever now() is right?

     

    However what I want is for the pre-populated value to be the Monday of the following week, which would correspond to one of the items in the lookup list, in the yyyy-mm-dd format (refer to attached picture in the main post; this format helps in sorting the dates chronologically).

     

    Is there any way to achieve this?

     

    Thanks

  • eka24 Profile Picture
    20,923 on at
    1. Insert  Dropdown2_1 set it Items to 'Activity List'.Week
    2. Insert a DatePicker1 and set its DefaultDate to Dropdown2_1.Selected.Week (You can also use a combobox. Set the visible of the Datepicker1 to false since users will not interact with it.
    3. In the Textbox the that you want the lookup:
      Text(DateValue(Text(DatePicker1.SelectedDate))+

              (9-Weekday(Today(),MondayZero)),"[$-en-US]yyyy-mm-dd")

     

    See Attached

     

    Please click and accept as Solution if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a Thumbs Up.

  • Community Power Platform Member Profile Picture
    on at

    [Delete]

  • Verified answer
    southern_cross Profile Picture
    13 on at

    Thanks for your reply @eka24 . I realise my message has been rather vague. I was able to figure out a solution, but your code has given me ideas for future functionalities in my app, so thank you.

     

    To those who come across this issue, my solution to a scenario - where I have a drop-down combo list of dates (which are strings) and I want to pre-populate (i.e. set DefaultSelectedItems) the field with the nearest future date - by setting DefaultSelectedItems to:

     

     

     

    Filter(Choices([@'Activity List'].Week),Value=First(Filter('Weeks List',Week > Today())).Weeks)

     

     

    Where 'Week' in the 'Weeks List' contain dates that are in the proper date format (dd/mm/yyyy).

     

    Hopes this helps anyone who is coming across this unique problem. Thanks

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

Forum hierarchy changes are complete!

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

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard