cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kumar9024021 Helper V
Helper V

Re: Gallery shows empty results eventhough Search keyword exists

Hi Yash@yashag2255 ,

 

Search Button OnSelect

UpdateContext({searchTerm:TextInput1.Text });UpdateContext({searchTerm1:TextInput1_2.Text });

UpdateContext({searchTerm2:TextInput1_3.Text });UpdateContext({searchTerm3:TextInput1_4.Text });

Gallery Items

Filter('DS',StartsWith(Event,searchTerm)||StartsWith(Organiser,searchTerm1)|| StartsWith(Status,searchTerm2)|| StartsWith(Where,searchTerm3))

 

When I used search earlier for single fields, I was able to get the search results for same datatype. All are mostly single line of text.

 

Is there any if,else i can add in Items Gallery ?

 

Dual Super User
Dual Super User

Re: Gallery shows empty results eventhough Search keyword exists

Hey @Kumar9024021 

 

Just so we are on same page, can you confirm below details:

1) You have inputs on the top and you want to filter based on them. The results in the gallery will only change when the button is clicked.

2) The StartsWith will only get the results where the value starts with the assigned variable.

Search operates on getting the results where the value exist even in the substrings.

Filter('DS',StartsWith(Event,searchTerm)||StartsWith(Organiser,searchTerm1)|| StartsWith(Status,searchTerm2)|| StartsWith(Where,searchTerm3))

When you are using this formula, are you getting any records when the button is clicked?

If no, check the variable value from View -> Variables -> then check if the variables hold the correct value.

If yes, but incorrect records, try taking baby steps in building this expression, like:
Filter('DS',StartsWith(Event,searchTerm))

Try adding all the filters one by one and observe the pattern.

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Kumar9024021 Helper V
Helper V

Re: Gallery shows empty results eventhough Search keyword exists

Hi @yashag2255 ,

 

Got your point. I noticed that when I key-in all the fields (Event,Organizer,Status,Where), gallery results shows fine as expected using below formula.

Filter('DS',StartsWith(Event,searchTerm)||StartsWith(Organiser,searchTerm1)|| StartsWith(Status,searchTerm2)|| StartsWith(Where,searchTerm3)).

I tried searching by keying-in only the Event textbox and left all 3 blank. Gallery results show me unexpected results. Screenshot below. When i search for ESR, it should show only ESR. But it shows with keyword "UAT" events, also despite using || in formula

Img4.PNGImg5.PNG

Dual Super User
Dual Super User

Re: Gallery shows empty results eventhough Search keyword exists

Hey @Kumar9024021 

 

That is happening because StartsWith considers search text ""(blank) as a valid input. To resolve this, you can update the expression as:

Filter('DS',If(Len(searchTerm)>0,StartsWith(Event,searchTerm))||If(Len(searchTerm1)>0,StartsWith(Organiser,searchTerm1))|| If(Len(searchTerm2)>0,StartsWith(Status,searchTerm2))|| If(Len(searchTerm3)>0,StartsWith(Where,searchTerm3)))

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Kumar9024021 Helper V
Helper V

Re: Gallery shows empty results eventhough Search keyword exists

Hi @yashag2255 ,

 

Thanks for your quick response. Search works fine now for text fields. However for date fields, I notice that search still doesn't work using below formula.

Filter('DS',If(Len(searchTerm)>0,StartsWith(Event,searchTerm))||If(Len(searchTerm1)>0,StartsWith(Organiser,searchTerm1))||If(Len(searchTerm2)>0,StartsWith(Status,searchTerm2))||If(Len(searchTerm3)>0,StartsWith(Where,searchTerm3)||When>DatePicker1.SelectedDate&&When<DatePicker1_1.SelectedDate))

 

I crosschecked the dateformat with datasource. Its same MM/DD/YYYY format. PFB screenshot. For textfields, I am storing the selected value in Search button OnSelect. Should we need to do same for dates ? I assume we have DatePicker. Selected property for that.

 

Img1.PNGImg2.PNG

 

 

Highlighted
Dual Super User
Dual Super User

Re: Gallery shows empty results eventhough Search keyword exists

Hey @Kumar9024021 

 

Its good that we are able to make the text fields work. Now, let do the same for the date type field.

It would be consistent to set the variable on Button click as if you use DatePicker.SelectedDate, the results in gallery will automatically refresh even if you do not click the button.

Also, set the format property of the DatePicker as "MM/DD/YYYY"


You can set the values as:

Button OnSelect -> UpdateContext({EventFrom: DatePicker1.SelectedDate, EventTo: DatePicker2.SelectedDate})

Gallery -> Items ->
Filter('DS',If(Len(searchTerm)>0,StartsWith(Event,searchTerm))||If(Len(searchTerm1)>0,StartsWith(Organiser,searchTerm1))||If(Len(searchTerm2)>0,StartsWith(Status,searchTerm2))||If(Len(searchTerm3)>0,StartsWith(Where,searchTerm3))|| And(When>EventFrom, When<EventTo))

If this does not work, try:

Filter('DS', When>EventFrom&&When<EventTo)

Can you confirm if this is a date type column in SP list? If it is not, then you might want to update the expression to:

Filter('DS', DateValue(Text(When,"MM/DD/YYYY")) >EventFrom && DateValue(Text(When,"MM/DD/YYYY"))<EventTo)

You can add the text filters later, first lets filter on dates.

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Kumar9024021 Helper V
Helper V

Re: Gallery shows empty results eventhough Search keyword exists

Hi Yash @yashag2255 ,

 

As requested, I have made the changes below for OnSelect to maintain consistency. I noticed that Filter('DS', When>EventFrom&&When<EventTo) works perfectly fine, without any issues.

 

However when combined with other fields like below, it cease to work. It always returns empty results in Gallery.

 

Filter('DS',If(Len(searchTerm)>0,StartsWith(Event,searchTerm))||If(Len(searchTerm1)>0,StartsWith
(Organiser,searchTerm1))||If(Len(searchTerm2)>0,StartsWith(Status,searchTerm2))||If(Len(searchTerm3)>0,StartsWith(Where,searchTerm3)||And(When>EventFrom,When<EventTo)))

 

Date format also crosschecked at all places. Its MM/DD/YYYY format.

 

 

Dual Super User
Dual Super User

Re: Gallery shows empty results eventhough Search keyword exists

Hi @Kumar9024021 

 

This is not working because of the bracket misplacement, please update the query as:

Filter('DS',
If(Len(searchTerm)>0,StartsWith(Event,searchTerm)) ||
If(Len(searchTerm1)>0,StartsWith(Organiser,searchTerm1)) ||
If(Len(searchTerm2)>0,StartsWith(Status,searchTerm2)) ||
If(Len(searchTerm3)>0,StartsWith(Where,searchTerm3)) ||
And(When>EventFrom,When<EventTo)
)

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

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