cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BeckyC
Frequent Visitor

Search for City or Number

I have a list that contains store names and the store number. I currently have a text search box that lets users enter the store name and it filters out to only show that name.  My powerapp shows them all listed out and the search works correctly.

 

I would like to add the option so that users could choose to enter either the store name the store number and it would then filter out the correct store.  

 

Currently my item for the gallery has:

SortByColumns(Filter([@'Store Locations'], StartsWith(Location, SearchInputBox.Text)), "Store", If(SortDescending1, Descending, Ascending))

 

 Is it possible to add filter by the store number as well?

 

 

A second question - I currently have STARTS WITH(location...  is there a way to say something like CONTAINS instead - so if the user types CITY and it is actually listed as N CITY then the correct store will still be found?

 

Thank you for your help

Becky

1 ACCEPTED SOLUTION

Accepted Solutions
FabianAckeret
Solution Sage
Solution Sage

Hi @BeckyC 

 

You could simply add another StartsWith() function separated with a ||.

Your formula could look like the following, while you'd need to replace <store ... field> with the corresponding field name:

SortByColumns(
    Filter([@'Store Locations'], 
    StartsWith(<store name field>, SearchInputBox.Text) ||
    StartsWith(<store number field>, SearchInputBox.Text)
    ) , 
    "Store", 
    If(SortDescending1, Descending, Ascending)
)

 

As for contains, in Power Apps this is called in.

You can use this operator for example like so:

LookUp(<source>, city in cities).city

 

I hope this helps.

 


Please click Accept as Solution if my post answered your question. Like my answer? Consider giving it a Thumbs Up. Others seeking the same answers will be happy you did.

View solution in original post

5 REPLIES 5
KrishnaV
Community Champion
Community Champion

Hi @BeckyC ,

 

you can change your filter as below:

SortByColumns(Filter([@'Store Locations'], (StartsWith(Location, SearchInputBox.Text)), "Store" || StartsWith(Location, SearchInputBox.Text)), "storenumber"), If(SortDescending1, Descending, Ascending))

unfortunately, PowerApps doesn't support Contains rather you can use in operator. To know more about that watch the below video I have explained how to use that:
https://www.youtube.com/watch?v=n3gOL32oy8s

 


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.
FabianAckeret
Solution Sage
Solution Sage

Hi @BeckyC 

 

You could simply add another StartsWith() function separated with a ||.

Your formula could look like the following, while you'd need to replace <store ... field> with the corresponding field name:

SortByColumns(
    Filter([@'Store Locations'], 
    StartsWith(<store name field>, SearchInputBox.Text) ||
    StartsWith(<store number field>, SearchInputBox.Text)
    ) , 
    "Store", 
    If(SortDescending1, Descending, Ascending)
)

 

As for contains, in Power Apps this is called in.

You can use this operator for example like so:

LookUp(<source>, city in cities).city

 

I hope this helps.

 


Please click Accept as Solution if my post answered your question. Like my answer? Consider giving it a Thumbs Up. Others seeking the same answers will be happy you did.

@KrishnaV 

 

darn... just realized you were faster 😛


Please click Accept as Solution if my post answered your question. Like my answer? Consider giving it a Thumbs Up. Others seeking the same answers will be happy you did.
BeckyC
Frequent Visitor

Thank to you both @KrishnaV  and  @FabianAckeret 

The 2nd solution worked for me - I couldn't get the other one to work but that might have been my fault. I had my store cities locations as a text field and the store number was a number field.  I thad changed the number field to text just now and then tried the 2nd solution and it worked.  

 

I do still need to look into the IN part of the formula and play with that some more. But thanks to you both I have the searching worked out.

 

Becky

BeckyC
Frequent Visitor

Here's the formula I ended up using so that you could find City as well as North City if you started typing the city name.

SortByColumns(
    Filter([@'Store Locations'], 
 SearchInputBox.Text in Store ||
 SearchInputBox.Text in Location
    ) , 
    "Store",
    If(SortDescending1, Descending, Ascending)
)

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (2,752)