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

How to add another Filter option when you already have a Date Picker

Hi All

 

I have a gallery in which i have already got a Date Picker that i am able to Filter by using the Formula in the Items in the gallery. 

If(IsBlank(DatePicker1.SelectedDate),'Harbour House Key History',Filter('Harbour House Key History', 'Date Out' = DatePicker1.SelectedDate))

 

I now want to add a Text input search function that will be able to filter on another column. also with the function that if the text input is blank i can see all results. 

 

Data Source: 'Harbour House Keys'

Column: 'Name in'

Text Input: TextInput1

 

Kind Regards

 

Justin 

 

1 ACCEPTED SOLUTION

Accepted Solutions
TylerPA
Resolver II
Resolver II

For the code above,

If(
    IsBlank(DatePicker1.SelectedDate),
    testList,
    Search(
        Filter(
            AddColumns(
                testList,
                "NameInFinal",
                nameIn.Email,
                "NameOutFinal",
                nameOut.Email
            ),
            dateCol = DatePicker1.SelectedDate
        ),
        TextInput1.Text,
        "NameInFinal",
        "NameOutFinal"
    )
)

 

I was able to get it working (tested using nameIn.Email and nameIn.DisplayName). Please check if displayname works instead? I noticed in my dataset, some names didn't have emails. Also, above had typo (assuming it's a cut/paste issue - missing 'i' of 'if')

 

For this small filter, that should work. If you are looking to filter with more parameters, I would recommend going back to the following format. I think all that was missing earlier, was the .DisplayName to access the properties of the person column. I was able to get both of below working

 

///
with delegation issue (if)
///

Filter(
    testList,
    If(
        IsBlank(DatePicker1),
        true,
        dateCol = DatePicker1.SelectedDate
    ),
    If(
        IsBlank(TextInput1),
        true,
        Or(
            TextInput1.Text in nameIn.DisplayName,
            TextInput1.Text in nameOut.DisplayName
        )
    )
)



///////
using collection
///////

Filter(
    collectTest,
    If(
        IsBlank(DatePicker1),
        true,
        dateCol = DatePicker1.SelectedDate
    ),
    If(
        IsBlank(TextInput1),
        true,
        Or(
            TextInput1.Text in nameIn.DisplayName,
            TextInput1.Text in nameOut.DisplayName
        )
    )
)

 

 

View solution in original post

19 REPLIES 19
TylerPA
Resolver II
Resolver II

Try setting up your filter this way; should allow you to add more options as needed

 

Filter(
'Harbour House Key History',
If(IsBlank(DatePicker1.SelectedDate), true, 'Date Out'=DatePicker1.SelectedDate),
If(IsBlank(TextInput1), true, 'Name in'=TextInput1.Text)
)
JEVANSAP
Helper II
Helper II

Hi Thank you for your reply 

 

I Tried this Formula and unfortunately this formula doesn't bring back any results for me in my gallery.  

JEVANSAP_0-1668083376030.png

 

I also got back a delegation warning on the date picker line. 

 

Kind regards

Justin

 

Can you check if the column is 'Name in' vs 'Name In'?

 

If you are trying to avoid delegation issues, I would recommend collecting the 'Harbour House Key History' during OnVisible

 

Clear(collectHistory);

Collect(collectHistory, 'Harbour House Key History');

 

And then filter collectHistory, instead of the source

NandiniBhagya20
Solution Sage
Solution Sage

Hi @JEVANSAP ,

If 'Name in' is of type choice, then you can use - 

Filter('Harbour House Keys', (IsBlank(DatePicker1.SelectedDate) || StartDate > DatePicker1.SelectedDate) And StartsWith('Name in'.Value, TextInput1.Text))


Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

JEVANSAP
Helper II
Helper II

I have added a collection as suggested 'CollectHistory' and done some testing on different variations of the formulas from the both of your reply's unfortunately these are still coming up with errors.

I think i might have to do it differently, instead of filtering on both, maybe i could do it where i can either Search Via date or Via Name.  

 

f(IsBlank(DatePicker1.SelectedDate),collectHistory,Filter('Harbour House Key History', 'Date Out' = DatePicker1.SelectedDate) Or Search(collectHistory,TextInput3.Text,"NameIn","NameOut"))

 

This is the formula i came up with but whatever i change i still get the message: The Function Search 'Search' Has some invalid Arguments. 

Hi @JEVANSAP ,

Try using below formula - 

If(IsBlank(DatePicker1.SelectedDate), collectHistory, Search(Filter('Harbour House Key History', 'Date Out' = DatePicker1.SelectedDate),TextInput3.Text,"NameIn","NameOut"))


Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

JEVANSAP
Helper II
Helper II

Hi @NandiniBhagya20 

 

I tried this formula and it still dosnt work. If i just have the formula for the date picker it works, but as soon as i want to add the text search in i get red X everywhere. I think i might have to just have the date picker as my only filter function. 

 

Kind Regards

 

Justin

Justin,

 

We should be able to figure this out; taking a step back

- What are the column types from your source for date, name?

- If you just put the text input as your filter, no date - what's the error message?

 

With the column types, I can try to build it out fully later

Try removing the collection and directly use the list name as data source - 

If(IsBlank(DatePicker1.SelectedDate), 'Harbour House Key History', Search(Filter('Harbour House Key History', 'Date Out' = DatePicker1.SelectedDate),TextInput3.Text,"NameIn","NameOut"))


Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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