cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dreamsat
Helper III
Helper III

How to clear a datepicker (leaving it blank)

I created an powerapp with a datepicker. The datepicker should show default the date of today. I created a clear button. I would like to make the datepicker empty when I click on this clear button. The datepicker should be blank. How to do this?

 

datepicker clear button.png

1 ACCEPTED SOLUTION

Accepted Solutions

In that case use two buttons, one for Blank and the other for Today.

 

Blank Button

UpdateContext ({MakeBlank:false)})

 

Today button;

UpdateContext ({MakeBlank:true)})

 

Maintain the formula on the DatePicker

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

View solution in original post

11 REPLIES 11
eka24
Super User
Super User

Once you make the default Today, it cannot be Blank at the same time. 

To work around it, insert a button and Onselect set a variable;

UpdateContext ({MakeBlank:! MakeBlank)})

 

Then put in the defaultdate;

If(MakeBlank,Today(), Blank ())

 

So when you click the button it can change from Today to blank and vice versa

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Do I need to create a variable with the name "MakeBlank" somewhere?

Yes I stated that in the reply, recheck

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

I see it. There was a small type. It should be: UpdateContext ({MakeBlank:! MakeBlank})

When I click on the clear button the first time it is doing what I expect. But when I click again on the clear button it sets the date of today. How can I avoid this behavior after the second click?

@dreamsat 
Use this code in the OnSelect property of your button.

Set(showBlankDate, true)

 

Then use this code in the Default property of the DatePicker.

If(showBlankDate, Blank(), Today())

 

 

---
Please click "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."

 

In that case use two buttons, one for Blank and the other for Today.

 

Blank Button

UpdateContext ({MakeBlank:false)})

 

Today button;

UpdateContext ({MakeBlank:true)})

 

Maintain the formula on the DatePicker

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Great, it works!

harioachira
Frequent Visitor

First , set the defaultDate to blank

harioachira_0-1654494368822.png

Then add the below simple code on the "OnSelect" event to the clear button

Reset(Datepickername)

 

 

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,565)