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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / auto populate today da...
Power Apps
Answered

auto populate today date if dropdown selection is selected

(0) ShareShare
ReportReport
Posted on by 71

Hi all! i have a dropdown called status and a date field called completion_date date 

i would like to auto populate today's date if the option Completed is selected in the completion_date date field 

Thank you

Capture.PNG

Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    Hi @aoghelian ,

    Set a Variable OnChange of the Status dropdown (I have assumed .Value is the output here)

    If(
     Self.Selected.Value = "Completed",
     UpdateContext({varSetToday: true})
    )

    then the Reset of the Date Picker

    varSetToday

    and the Default of the Date Picker (I am assuming it is Parent.Default now)

    If(
     varSetToday,
     Today(),
     Parent.Default
    )

    and lastly at Screen OnVisible

    UpdateContext({varSetToday: false})

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

     

  • aoghelian Profile Picture
    71 on at

    @WarrenBelz worked like a charm!! Thank you!! 

  • lotrix Profile Picture
    10 on at

    Hi @WarrenBelz,

    I have the exact same scenario and your solution worked perfectly. However, could you help me creating a minor modification:
    If the "Completion Date" picker is empty and the dropdown is set to "completed", then the today's date should be inserted....but if a completion date has already been entered BEFORE the dropdown is set to "completed" then the entered completion date should remain. THank you for your help.

  • WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    Hi @lotrix ,

    DefaultDate would be something like this

    If(
     varSetToday,
     Coalesce(
     ThisItem.CompletionDate,
     Today()
     ),
     ThisItem.CompletionDate
    )

     

  • lotrix Profile Picture
    10 on at

    @WarrenBelz 

    There is still an issue: When I first select the 7/1/2023 as completion date and then set the dropdown to "complete", it changes the completion date to todays date 7/15/2023. Any suggestions?

  • lotrix Profile Picture
    10 on at

    It seems as if the ThisItem.'Close Date' is not not correctly evaluated and the if function always returns the TODAY date. 

    lotrix_0-1689421242494.png

     

  • WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    @lotrix ,

    Dates are not always blank - try

    If(
     varSetToday,
     If(
     Value(ThisItem.CompletionDate) < 1,
     Today(),
     ThisItem.CompletionDate
     ),
     ThisItem.CompletionDate
    )

    I am assuming you are using SharePoint here.

     

  • lotrix Profile Picture
    10 on at

    Further issue, when I save the form, the close date seems to get cleaned. It is not saved in the sharepoint list. When I click on Edit Item again, then there is no close date available...

  • WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    @lotrix ,

    Sorry, I do not know what you mean - the only possibilities here are

    • If you have a date in your list it will show the date
    • If varToday is true, it will show the current date

     

  • lotrix Profile Picture
    10 on at

    @WarrenBelz 

    What I am trying to say is: Even when I entered a date in the Completion Date field and hit SAVE on the form, the Completion Data is not being saved in the sharepoint list. When I re-visit the form, the Completion Date is empty.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard