cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Filtering a gallery - need next 30 days

Hi, 

 

I have a gallery and 2 buttons that says 'Next 30 Days' and 'All'. I need the gallery to filter based upon the selected button for trips with a departure date occurring in the next 30 days as well as resetting back to show everything when 'All' is selected. 

 

How can I accomplish this?

 

1 ACCEPTED SOLUTION

Accepted Solutions
eka24
Super User III
Super User III

On the OnSelect of the All Button put:

UpdateContext({varAll:!varAll}))

 

On the OnSelect of the 30Day Button put:

UpdateContext({varAll:!varAll}))

 

Then filter as follows;

If(varAll, Datasource,

Filter(Datasource,

DateDiff(DateColumn,Today(),Days)>=30))

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

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

7 REPLIES 7
nate_halliwell
Advocate I
Advocate I

@Anonymous you could make the "Items" in the Gallery to a variable like 'VarGalleryData'....then OnSelect of the next 30 days button = UpdateContext({VarGalleryData:Filter(datasource,departuredatecolumn <= today()+30)})

 

then the OnSelect of the "All Items" button would = UpdateContext{(VarGalleryData:datasource})

 

on Screen Visible, make VarGalleryData whatever you want the gallery to show as a default.

 

Good Luck!

eka24
Super User III
Super User III

On the OnSelect of the All Button put:

UpdateContext({varAll:!varAll}))

 

On the OnSelect of the 30Day Button put:

UpdateContext({varAll:!varAll}))

 

Then filter as follows;

If(varAll, Datasource,

Filter(Datasource,

DateDiff(DateColumn,Today(),Days)>=30))

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

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

Anonymous
Not applicable

The OnSelect for both buttons should be the same?

eka24
Super User III
Super User III

If you are using only one button, that would be okay. With 2 buttons try;

 

On the OnSelect of the All Button put:

UpdateContext({varAll:true}))

 

On the OnSelect of the 30Day Button put:

UpdateContext({varAll:false}))

 

Then filter as follows;

If(varAll=false, Datasource,

Filter(Datasource,

DateDiff(DateColumn,Today(),Days)>=30))

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

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.

in @eka24 's solution, yes, because the ! before the variable in his example means make the variable opposite of what it is now. in other words, if you think of it in terms of true/false....both buttons say if x is true, make it false, or if x is false, make it true.....i am terrible at typing out what i mean, but i hope this adds a little clarity.

Anonymous
Not applicable

Am I supposed to filter the gallery on the Items property?

Yes put the formula on the Items property of the Gallery.

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

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.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (14,372)