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 / Date Picket sits outsi...
Power Apps
Answered

Date Picket sits outside of form to equal value of form field if not blank else now()

(0) ShareShare
ReportReport
Posted on by

Hello All,

still new to this great tool called Power Apps and cannot find the answer I need.

I have a Date Picker field that sits outside a form called "Date_P".

I have a form called "Mainform" with the value of the date sitting in "DataCardValue1".

this is what I would like to do.
      A) if "DataCardValue1" is Blank then "Date_P" = now() else "DataCardValue1".
      B) if "Mainform" is in display mode then "Date_P" will be in display mode else in edit mode

Star_Citizen_0-1699399087361.png

I feel I need to focus on the "Default" and "Visible" components of "Date_P" but the issue I am having is every time I try to reference the form field I get an error.
eg I am able to get the field value with "Project_Look.Selected.Head_Line_Date" (Head_Line_Date is the name of the field on the SharePoint site)
but when I try to put it in an if statement I get an error
eg if(ISBLANK(Project_Look.Selected.Head_Line_Date,NOW(),Project_Look.Selected.Head_Line_Date)

thankyou friends
Frank

Categories:
  • MudassarSZ365 Profile Picture
    591 on at

    Hi @Star_Citizen ,

    Setting the DatePicker Default Date
    For the DefaultDate property of the DatePicker control Date_P, you want to show the current date/time if a certain value in the form is blank, otherwise show the value from the form. The formula would look something like this:

    If(
     IsBlank(LookUp(MainDataSource, ID = Mainform.LastSubmit.ID).Head_Line_Date),
     Now(),
     LookUp(MainDataSource, ID = Mainform.LastSubmit.ID).Head_Line_Date
    )

    Setting the DatePicker Display Mode
    For the DisplayMode property of the DatePicker control Date_P, you want it to be in display mode if the form is in display mode and in edit mode otherwise. The formula for this would be:

    If(
     Mainform.Mode = FormMode.Edit,
     DisplayMode.Edit,
     DisplayMode.View
    )

    If you get errors regarding the reference to the form field, ensure that the DataCardValue1 reference is correctly pointing to the data card value within the form that holds the date. If DataCardValue1 is the correct name, your formula should work if you replace the lookup logic with the reference to the data card. For instance:

    If(
     IsBlank(DataCardValue1.Text),
     Now(),
     DateValue(DataCardValue1.Text)
    )
    

    This will look up the tab in the collection where the TabId matches the CurrentTabId.

    Kindly mark the solution as accepted if it resolves your issue.

    Best Regards
    Muhammad Mudassar Mazhar

  • Star_Citizen Profile Picture
    on at

    Hello Muhammad,
    Thank you for answering my question, The Display Mode answer you supplied is working..
    Unfortunately, I am getting an error when implementing the "Default Date" solution. I hope I gave you all the information required, just in case I will paste below a representation of the Screen I have.
    Like I mentioned the Date picker sits outside the form itself.
    I assumed when you said "MainDataSource" you mean the name of my SharePoint file I am linking to, which is.
    'PM Status Tracker'.

     

     

    Star_Citizen_3-1699406641943.png

     

     

  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @Star_Citizen,

    A) if "DataCardValue1" is Blank then "Date_P" = now() else "DataCardValue1".

    To achieve this, please set the DefaultDate of the Date_P as below:

    If(IsBlank(DataCardValue1.SelectedDate),Today(),DataCardValue1.SelectedDate)

    B) if "Mainform" is in display mode then "Date_P" will be in display mode else in edit mode

    To achieve this, please set the DisplayMode property of the Date_P as below:

    If(Mainform.Mode = FormMode.View,DisplayMode.View,DisplayMode.Edit)

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 394 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

Last 30 days Overall leaderboard