cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
AGaudioASG
Level: Powered On

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
Super User
Super User

Re: When not filtered, no results show up.

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

Super User
Super User

Re: When not filtered, no results show up.

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
Super User
Super User

Re: When not filtered, no results show up.

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

AGaudioASG
Level: Powered On

Re: When not filtered, no results show up.

That worked perfectly thank you!!

AGaudioASG
Level: Powered On

Re: When not filtered, no results show up.

@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.

 

Super User
Super User

Re: When not filtered, no results show up.

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

AGaudioASG
Level: Powered On

Re: When not filtered, no results show up.

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!!

Super User
Super User

Re: When not filtered, no results show up.

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

Helpful resources

Announcements
thirdimage

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,015)