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

Dynamically set date picker range with buttons?

I currently have a two date pickers which filter the date column of a gallery. One date picker is the start date and the other is the end date to filter.

 

How can I use a variable to dynamically filter the dates of the date picker?

 

The two dynamic ranges I'd like to set with two separate buttons are:

This whole month 

Last whole month

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @Blacksmith354 ,

 

The variable is only one.

And you can put it inside your OnSelect button.

 

buttonThisMonth :

UpdateContext({varThisMonth: true})

 

buttonLastMonth :

UpdateContext({varThisMonth: false})

 

And this is for the datepicker DefaultDate with switch :

Switch(varThisMonth,
true, Date(Year(Today()),Month(Today()),1),
false, DateAdd(Date(Year(Today()),Month(Today()),1), -1, Months))

 

View solution in original post

4 REPLIES 4
rizkyaditya
Resolver III
Resolver III

Hello @Blacksmith354 ,

 

You can try this inside the DefaultDate property of your date picker :

Switch(yourVariable,
yourVariableValue1, Date(Year(Today()),Month(Today()),1),
yourVariableValue2, DateAdd(Date(Year(Today()),Month(Today()),1), -1, Months))

 

I hope this helps!

@rizkyaditya 

 

This suggestion seems to involve 3 variables and a switch. But I'm lost on how and where to put and set these variables as.

Hello @Blacksmith354 ,

 

The variable is only one.

And you can put it inside your OnSelect button.

 

buttonThisMonth :

UpdateContext({varThisMonth: true})

 

buttonLastMonth :

UpdateContext({varThisMonth: false})

 

And this is for the datepicker DefaultDate with switch :

Switch(varThisMonth,
true, Date(Year(Today()),Month(Today()),1),
false, DateAdd(Date(Year(Today()),Month(Today()),1), -1, Months))

 

Blacksmith354
Frequent Visitor

@rizkyaditya I was able to easily use this to create two variables since there are two date pickers. Thank you.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,902)