cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mokhawaja
Kudo Collector
Kudo Collector

Search/Filter nested functions with wrong behaviour!!

Hi,

i am having a gallery which i need to filter based on a selection from a combobox (single selection), and keep the search function on the results, here is the formula:

 

Filter(Search(Doctors, TextInput6.Text,"DoctorName"), City=ComboBox2.Selected.Value)

so on this formula we have 3 scinarios:

1. the user use the filter only, and result as expected the records will be filtered by City (even if the user did not make a selection, the gallery will remain blank)

2. the user search by text, and the gallery displays the results with no problem.

3. (here is the problem), when the user select a city, then enter text to find the doctor inside that city the results shown are from all cities, which means the filter is not working while the search is working!!

 

 

i tried to invert the formula (filter is inside the filter) with the same results.

 

so I need to retain the filter and search on the results of the filter.

 

appreciate your advice.

 

Mohammad

4 REPLIES 4
mokhawaja
Kudo Collector
Kudo Collector

Hi,

please comment, or advise on my issue.

 

thanks

Moahammad

Anonymous
Not applicable

 Hi @mokhawaja

 

Try to use this formula, I tested it on Test SharePoint List and it filters like you want.

 

 

Gallery.Items:

If(
    CountRows(ComboBox2.SelectedItems) > 0 && !IsBlank(TextInput6.Text),
    Filter(
        Doctors,
        City in ComboBox2.SelectedItems.Value,
        StartsWith(Title,TextInput6.Text)
    ),
    CountRows(ComboBox2.SelectedItems) > 0,
    Filter(
        Doctors,
        City in ComboBox2.SelectedItems.Value
    ),
    !IsBlank(TextInput6.Text),
    Filter(
        Doctors,        
        StartsWith(Title,TextInput6.Text)
    ),
    Doctors
)

 

thanks @Anonymous for your reply... it worked with limited functionalty, unfortunately my datasourse is CDS and startswith function is non delegable on CDS!!

 

actually i beleive my function should work fine, but i think there is some kind of a bug or something.

 

thanks,

Mohammad

Anonymous
Not applicable

I managed to find a solution for this problem, in which i used Collections.

 

So for the first level of filteration:

ClearCollect(nameofCollectionvar,Filter(tablename,field1=value1 && field2= value2));

 

you will then use the same collection you generated above for the below search

Search(nameofCollectionvar,textfield.txt,"field3","field4"))

 

hope this works for you

Helpful resources

Announcements
User Groups Public Preview

Join us for our User Group Public Preview!

Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

Power Apps Community Call

Monthly Power Apps Community Call

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

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 (66,000)