cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
simms7400
Level 8

Search Multiple Columns - Text & Choice

Hi Folks -

 

I have a search box and galley set up on one of my form. I've also enabled it where the user can search multple fields as well. Here is my formula:

SortByColumns(
	Filter(rdAssets, 
		StartsWith(Alias, TextSearchBox4.Text) || 
		StartsWith(Name, TextSearchBox4.Text) ||
		StartsWith(Target_x0020_Short_x0020_Name, TextSearchBox4.Text) ||
		StartsWith(Brand_x0020_Name, TextSearchBox4.Text) ||
		StartsWith(PF_Research_Code, TextSearchBox4.Text) ||
		StartsWith(Generic_x0020_Name, TextSearchBox4.Text) ||
		StartsWith(Development_Name, TextSearchBox4.Text) ||
		StartsWith(Alternate_Name, TextSearchBox4.Text) && !(Portfolio_x0020_Status.Value="Terminated")), 
		"Alias", If(SortDescending1, Descending, Ascending)
	)

It's currently sorted by "Alias" (which is a text field), however I need to add one more column to sort by : Portfolio_x0020_Status

The issue is the Portfolio_x0020_Status is a choice field and it's not liking any formula. Can somene give me some pointers on how to add Portfolio_x0020_Status to my above formula?

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Search Multiple Columns - Text & Choice

@simms7400 

Give this a try:

 

SortByColumns(
	AddColumns(
Filter(rdAssets, StartsWith(Alias, TextSearchBox4.Text) || StartsWith(Name, TextSearchBox4.Text) || StartsWith(Target_x0020_Short_x0020_Name, TextSearchBox4.Text) || StartsWith(Brand_x0020_Name, TextSearchBox4.Text) || StartsWith(PF_Research_Code, TextSearchBox4.Text) || StartsWith(Generic_x0020_Name, TextSearchBox4.Text) || StartsWith(Development_Name, TextSearchBox4.Text) || StartsWith(Alternate_Name, TextSearchBox4.Text) && !(Portfolio_x0020_Status.Value="Terminated")
),
"txtPortfolioStatus", Portfolio_x0020_Status.Value), "Alias", If(SortDescending1, Descending, Ascending),
"txtPortfolioStatus", If(SortDescending1, Descending, Ascending) )

This will augment your results of your Filter table with an additional column, which is the value of the Portfolio Status column.  You can then use that added column in your sort.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
11 REPLIES 11
RezaDorrani
Level 10

Re: Search Multiple Columns - Text & Choice

Hi @simms7400 

 

Use the Sort function

 

Sort( <filter condition>, Portfolio_x0020_Status.Value, <Ascending or Descending>)   

 

Regards,

Reza

simms7400
Level 8

Re: Search Multiple Columns - Text & Choice

@RezaDorrani 

 

Hi - thank you. but I need to do Alias and Portfolio_x0020_Status.Value.

 

? Thanks!

Super User
Super User

Re: Search Multiple Columns - Text & Choice

@simms7400 

Give this a try:

 

SortByColumns(
	AddColumns(
Filter(rdAssets, StartsWith(Alias, TextSearchBox4.Text) || StartsWith(Name, TextSearchBox4.Text) || StartsWith(Target_x0020_Short_x0020_Name, TextSearchBox4.Text) || StartsWith(Brand_x0020_Name, TextSearchBox4.Text) || StartsWith(PF_Research_Code, TextSearchBox4.Text) || StartsWith(Generic_x0020_Name, TextSearchBox4.Text) || StartsWith(Development_Name, TextSearchBox4.Text) || StartsWith(Alternate_Name, TextSearchBox4.Text) && !(Portfolio_x0020_Status.Value="Terminated")
),
"txtPortfolioStatus", Portfolio_x0020_Status.Value), "Alias", If(SortDescending1, Descending, Ascending),
"txtPortfolioStatus", If(SortDescending1, Descending, Ascending) )

This will augment your results of your Filter table with an additional column, which is the value of the Portfolio Status column.  You can then use that added column in your sort.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
simms7400
Level 8

Re: Search Multiple Columns - Text & Choice

@RandyHayes  Hi Randy -

 

As usual, youre a wizard! Worked like a charm. I switched the Portfolio_Status with Alias so it sorts Alias first, but all is good.

 

Thank you so much!

simms7400
Level 8

Re: Search Multiple Columns - Text & Choice

@RandyHayes  Actually, I  am running into an issue.

 

I applied this logic to my gallery,  per your suggestion.:

SortByColumns(
	AddColumns(
             Filter(rdAssets, 
		StartsWith(Alias, TextSearchBox4.Text) || 
		StartsWith(Name, TextSearchBox4.Text) ||
		StartsWith(Target_x0020_Short_x0020_Name, TextSearchBox4.Text) ||
		StartsWith(Brand_x0020_Name, TextSearchBox4.Text) ||
		StartsWith(PF_Research_Code, TextSearchBox4.Text) ||
		StartsWith(Generic_x0020_Name, TextSearchBox4.Text) ||
		StartsWith(Development_Name, TextSearchBox4.Text) ||
		StartsWith(Alternate_Name, TextSearchBox4.Text) && !(Portfolio_x0020_Status.Value="Terminated")
                    ), 
             "txtPortfolioStatus", Portfolio_x0020_Status.Value),
   "txtPortfolioStatus", If(SortDescending1, Descending, Ascending),
   "Alias", If(SortDescending1, Descending, Ascending)
)

However, one of my properites on my EditForm is not rendering now.  My Items property (AssetBrowseGallery.Selected) is now saying:

"Invalid Formula.  Expected a value compatible with DataSource."

 

Is this because I'm using the Portfolio_Status filter as well?

 

Super User
Super User

Re: Search Multiple Columns - Text & Choice

@simms7400 

Ah yes, you most likely have a Item property on the Form set to GalleryX.Selected

With the formula I provided, this will break those situations.

The quick fix is this on your Form Item property:

  First(DropColumns(Table(Galleryx.Selected), "txtPortfolioStatus"))

 

That should resolve that.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
simms7400
Level 8

Re: Search Multiple Columns - Text & Choice

@RandyHayes 

 

Hi Randy, thank you! Just tried your formula on my EditForm Item property and still getting same error.

 

Keep in mind, my Gallery and Edit form are two seperate things, does that matter? Thanks!

Super User
Super User

Re: Search Multiple Columns - Text & Choice

@simms7400 

So, your Gallery is based on rdAssets and your EditForm as well I assume.

What is your formula for your EditForm Item property?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
simms7400
Level 8

Re: Search Multiple Columns - Text & Choice

@RandyHayes  Hi Randy,

 

my formula is the one you provided above for my Item property on my EditForm.   Thanks!

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 4 members 2,894 guests
Please welcome our newest community members: