cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AGaudioASG
Helper II
Helper II

When not filtered, no results show up.

I have a calendar, search box and checkbox filters. They function, except for the face that when no filters are applied there is nothing in the gallery. 

 

It should be when no dates are selected (or any other filter) ALL the classes are shown. 

 

Here is my current formula.

SortByColumns(
If(
CheckboxAdmin.Value,Filter('Test:CourseCatalog',Category.Value="Administrative" && _selectionStart<=StartDate && _selectionEnd>=EndDate),
CheckboxConstruct.Value, Filter('Test:CourseCatalog',Category.Value="Construction" && _selectionStart<=StartDate && _selectionEnd>=EndDate) ,
CheckboxGen.Value, Filter('Test:CourseCatalog',Category.Value="General" && _selectionStart<=StartDate && _selectionEnd>=EndDate),
CheckboxSafe.Value, Filter('Test:CourseCatalog',Category.Value="Safety" && _selectionStart<=StartDate && _selectionEnd>=EndDate),
Search(Filter('Test:CourseCatalog',_selectionStart<=StartDate && _selectionEnd>=EndDate), TextSearchBox1.Text, "Title")),"Date")

 

 

Can anyone help?

2 ACCEPTED SOLUTIONS

Accepted Solutions
wyotim
Resident Rockstar
Resident Rockstar

You might try adding a condition for a blank date. This is what I have had to do with similar filter situations. Something like:

SortByColumns(
    If(
        CheckboxAdmin.Value,
        Filter(
            'Test:CourseCatalog',
            Category.Value = "Administrative" && (_selectionStart <= StartDate || _selectionStart = Blank()) && (_selectionEnd >= EndDate || _selectionEnd = Blank())
        ),
        CheckboxConstruct.Value, 
        Filter(
            'Test:CourseCatalog',
            Category.Value = "Construction" && (_selectionStart <= StartDate || _selectionStart = Blank()) && (_selectionEnd >= EndDate || _selectionEnd = Blank())
        ),
        CheckboxGen.Value, 
        Filter(
            'Test:CourseCatalog',
            Category.Value = "General" && (_selectionStart <= StartDate || _selectionStart = Blank()) && (_selectionEnd >= EndDate || _selectionEnd = Blank())
        ),
        CheckboxSafe.Value, 
        Filter(
            'Test:CourseCatalog',
            Category.Value = "Safety" && (_selectionStart <= StartDate || _selectionStart = Blank()) && (_selectionEnd >= EndDate || _selectionEnd = Blank())
        ),
        Search(
            Filter(
                'Test:CourseCatalog',
                (_selectionStart <= StartDate || _selectionStart = Blank()) && (_selectionEnd >= EndDate || _selectionEnd = Blank())
            ), 
            TextSearchBox1.Text, 
            "Title"
        )
    ),
    "Date"
)

 

Maybe try that out as a start? The main idea is that if the respective date is blank, return true, which basically nullifies that section of the filter. Let me know if it works out for you or not; I'd be happy to follow up if needed!

View solution in original post

wyotim
Resident Rockstar
Resident Rockstar

From your code above, it looks like you have four checkboxes, two dates, and a text search, right? And are you using date pickers to get those dates? I didn't see a .SelectedDate in your code, so I wasn't sure how you were getting those dates in there. I assume you are referencing the control name to get it? Using ControlName.SelectedDate is a cleaner way to do that, especially if you have to write it to a data source.


To reset the controls to a default state, they each have a Reset property. This takes a boolean value (true/false) and on true, reverts to whatever Default the control has set. For date pickers, the Default is Today() so you might have to clear that out for it to default to a blank date or set it to whatever you want it to be, like DateAdd(Today(), -7, Days) for it to default to a week before today, etc.

 

So basically, you will want to create a local variable to reset each of those controls. Something like this:

UpdateContext({varResetControls: false});
UpdateContext({varResetControls: true})

 This basically sets the variable to false and then true. I've found that you have to do something like this where the variable has an "off" state so it knows that the "on" state has been triggered. Otherwise, once it is set to true, it will not know that setting it to true again is a state change. Hopefully, that makes sense!

 

So in the Reset property of each control, put varResetControls (or whatever you name your variable). Then put that code above (or your modified version) in the OnSelect of the control that will do the resetting. That chunk of code can go at the start or end of any other code you may have in there. (At the end if you are writing data and resetting controls so it doesn't reset them first and then write the default values instead of ones you chose!)

 

Let me know if that solves the issue or not, or if I can clarify anything! 

View solution in original post

6 REPLIES 6
wyotim
Resident Rockstar
Resident Rockstar

You might try adding a condition for a blank date. This is what I have had to do with similar filter situations. Something like:

SortByColumns(
    If(
        CheckboxAdmin.Value,
        Filter(
            'Test:CourseCatalog',
            Category.Value = "Administrative" && (_selectionStart <= StartDate || _selectionStart = Blank()) && (_selectionEnd >= EndDate || _selectionEnd = Blank())
        ),
        CheckboxConstruct.Value, 
        Filter(
            'Test:CourseCatalog',
            Category.Value = "Construction" && (_selectionStart <= StartDate || _selectionStart = Blank()) && (_selectionEnd >= EndDate || _selectionEnd = Blank())
        ),
        CheckboxGen.Value, 
        Filter(
            'Test:CourseCatalog',
            Category.Value = "General" && (_selectionStart <= StartDate || _selectionStart = Blank()) && (_selectionEnd >= EndDate || _selectionEnd = Blank())
        ),
        CheckboxSafe.Value, 
        Filter(
            'Test:CourseCatalog',
            Category.Value = "Safety" && (_selectionStart <= StartDate || _selectionStart = Blank()) && (_selectionEnd >= EndDate || _selectionEnd = Blank())
        ),
        Search(
            Filter(
                'Test:CourseCatalog',
                (_selectionStart <= StartDate || _selectionStart = Blank()) && (_selectionEnd >= EndDate || _selectionEnd = Blank())
            ), 
            TextSearchBox1.Text, 
            "Title"
        )
    ),
    "Date"
)

 

Maybe try that out as a start? The main idea is that if the respective date is blank, return true, which basically nullifies that section of the filter. Let me know if it works out for you or not; I'd be happy to follow up if needed!

View solution in original post

That worked perfectly thank you!!

@wyotim - Maybe you can help with my new issue. I cant get my reload button to reset the search parameters. So after I make a date selection, and then unselect it, it does not revert back to the blank selection default. so I thought if I reset the gallery or the calendar that would help but it did not work.

 

wyotim
Resident Rockstar
Resident Rockstar

From your code above, it looks like you have four checkboxes, two dates, and a text search, right? And are you using date pickers to get those dates? I didn't see a .SelectedDate in your code, so I wasn't sure how you were getting those dates in there. I assume you are referencing the control name to get it? Using ControlName.SelectedDate is a cleaner way to do that, especially if you have to write it to a data source.


To reset the controls to a default state, they each have a Reset property. This takes a boolean value (true/false) and on true, reverts to whatever Default the control has set. For date pickers, the Default is Today() so you might have to clear that out for it to default to a blank date or set it to whatever you want it to be, like DateAdd(Today(), -7, Days) for it to default to a week before today, etc.

 

So basically, you will want to create a local variable to reset each of those controls. Something like this:

UpdateContext({varResetControls: false});
UpdateContext({varResetControls: true})

 This basically sets the variable to false and then true. I've found that you have to do something like this where the variable has an "off" state so it knows that the "on" state has been triggered. Otherwise, once it is set to true, it will not know that setting it to true again is a state change. Hopefully, that makes sense!

 

So in the Reset property of each control, put varResetControls (or whatever you name your variable). Then put that code above (or your modified version) in the OnSelect of the control that will do the resetting. That chunk of code can go at the start or end of any other code you may have in there. (At the end if you are writing data and resetting controls so it doesn't reset them first and then write the default values instead of ones you chose!)

 

Let me know if that solves the issue or not, or if I can clarify anything! 

View solution in original post

So my calendar was a gallery that I got from a template. Instead of banging my head against the wall trying to figure it out, I created two date pickers with the condition that it would be blank if there was no selection on the calendar. Wham Bam Thank you Mam!

 

Worked like a charm. Thanks for your help!!

wyotim
Resident Rockstar
Resident Rockstar

Happy to be able to assist! Hit me up if I can help out in the future!

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 Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

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

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (45,992)