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

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

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