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

Search function include text and choices

I created a new Canvas App. I am using a CDS table as my data source. I created all of the necessary columns in my table to store my data.  I added 2 dummy records to my data. I am now configuring a screen that will show the records in a gallery.  I am able to get the gallery to populate ok (with the help from this group...thank you!), but I'm now trying to add a search box to the screen so that my users can filter the data and show only interesting records.  The problem is that some of the fields in my CDS data source are "Choices" fields, not simple text fields.  This makes the search function throw the error that it expects a text field (of course).  I've tried using the AddColumns function but I don't think I quite understand how to structure or use this, below is one of the variations of what I've tried so far.  My understanding is I point it to my data source (CDS_DATASOURCE), then give the "virtual" column a name (txtFunction) and then tell it what column to feed into that virtual column (Recommendation Number).  Then I reference the search box and point it to the virtual column and it should populate my gallery based on the user's input.  Not working...so I'm obviously doing this wrong.  Any assistance would be appreciated!  

 

Search(AddColumns(CSD_DATASOURCE, "txtFunction", 'Recommendation Number', SearchInputBox.Text,"txtFunction"))

 

Thanks,

Randy

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft
Microsoft

Hi @RDJHUD ,

 

I think there is a little problem with the function you are using. Firstly, you should put the text value of Choices Column in "virtual" column, but you used 'Recommendation Number' directly in your function.

I advise you to put the text value of Choices Column in "virtual" column which named (txtFunction), Because you use Choice column, you should use Concat() function to convert multi value to text.

Please try to use the function as below:

Search(AddColumns(Projects,"txtFunction",Concat(choiceTT,Value &",")),TextInput2.Text,"txtFunction")

Here is the result in my side:

v-yangar-msft_0-1610359070827.png

 

In the previous screenshot, ChoiceTT is the Choices column in my CDS table. Porject5 relates to cate2 and cate7 as below:

v-yangar-msft_1-1610359070829.png

 

When I type cate2 or cate7, both of results are project5:

v-yangar-msft_2-1610359070831.jpeg

 

v-yangar-msft_3-1610359070832.jpeg

 

 

 

Help it helps!

 

Many Thanks,

Arrow

View solution in original post

3 REPLIES 3
Super User II
Super User II

Hi @RDJHUD 

I would leave the textinput box and add a dropdown for the choices.  You could then filter for both controls in the items property of the gallery. The real value of a choice type field is to be able to show them in a toggle (2 choices), radio control (several),  dropdown (many choices), or combo box (so many you have to search them to narrow the choices).

Resolver I
Resolver I

Hi @RDJHUD ,

 

AddColumns returns table by adding, dropping, renaming, and selecting its columns.

To achieve your functionality, use "filter" formula. Search function finds records in a table that contain a string in one of their columns.

ex: Below formula it to filter accounts based on account name and status reason. you can add any number of logical test.

Filter(Accounts, 'Account Name' = TextSearchBox4.Text, 'Status Reason' = 'Status Reason (Accounts)'.Active)

If you have any dropdown in an app for filter. you can use below formula. I have added sample dropdown FYR.

Filter(Accounts, 'Account Number' = Dropdown3.Selected.'Account Number' || 'Account Name' = TextSearchBox4.Text, 'Status Reason' = 'Status Reason (Accounts)'.Active)


Including reference link from docs:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-filter-lookup


Mark it as resolved, if it answers your problem.

 

Regards,
Prakash

Microsoft
Microsoft

Hi @RDJHUD ,

 

I think there is a little problem with the function you are using. Firstly, you should put the text value of Choices Column in "virtual" column, but you used 'Recommendation Number' directly in your function.

I advise you to put the text value of Choices Column in "virtual" column which named (txtFunction), Because you use Choice column, you should use Concat() function to convert multi value to text.

Please try to use the function as below:

Search(AddColumns(Projects,"txtFunction",Concat(choiceTT,Value &",")),TextInput2.Text,"txtFunction")

Here is the result in my side:

v-yangar-msft_0-1610359070827.png

 

In the previous screenshot, ChoiceTT is the Choices column in my CDS table. Porject5 relates to cate2 and cate7 as below:

v-yangar-msft_1-1610359070829.png

 

When I type cate2 or cate7, both of results are project5:

v-yangar-msft_2-1610359070831.jpeg

 

v-yangar-msft_3-1610359070832.jpeg

 

 

 

Help it helps!

 

Many Thanks,

Arrow

View solution in original post

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

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

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (33,528)