SELECT() Expression

tvinci
New Member

Hello AppSheet Community

I wrote the below expression to retrieve name values from the locations table whose Route is Broward and are designated as Mandatory AM:

sort(select(locations[name],and([Route?]="Broward",[Mandatory AM?]="TRUE")))

So when I double-check it it makes sense to me, but thereโ€™s a bug in my app where this expression is returning stops from other routes as well. How do I correct this expression to be more specific?

Thank you.
-Tiffany

0 19 334
19 REPLIES 19

What type of a column is [Route?]? Make sure AppSheet didnโ€™t autoset that column to be a yes/no column which it will do when you have a question mark in the column name. Also remove the quotes around true since you are checking true or false and not for the text โ€œtrueโ€. It may or may not matter, but just in case.

[Route?] is an Enum type. Should I change that?
I also tried using FILTER() instead of SELECT() but nothing changed.

Enum should be fine. I you temporarily add rich.ellis@appsheet.com to view your app definition, I can take a look and see what could be causing it.

Okay I did it. The column is Products in the Clipboard table and the large expression is under Auto Compute -> Suggested Values.

Thank you.

Yeah the problem is with the double quotes around true.
change the select() to this:

sort(select(locations[name],and([Route?]=โ€œBrowardโ€,[Mandatory AM?]=true)))

I did this and it didnโ€™t make a difference for some reason. Is the problem the uppercase letters?

Since when?

Also, [Mandatory AM?]=true is redundant; [Mandatory AM?] is enough if the column type is Yes/No.

Yep the type is YES/NO. I checked.

Here is a test of row 4 with TRUE:

Row 4 with โ€œTRUEโ€ quotes:

@Steve not sure I have always found it to cause me issues at times, so I never use quotes with y/n columns

Isnโ€™t this picture just the same results no matter the quotation marks? Maybe Iโ€™m misreading it.

No the results are in the left column. The first one returns 2 items, the second one has zero.

Other columns are blank when the quotes are used and not blank when no quotes are used. I checked in the table and it appears to be producing the correct results.

Steve
Platinum 4
Platinum 4

Do the โ€œother routesโ€ have blank Route? column values?

Yes! Although I thought if the Route? column value was blank then the expression would evaluate to false and exclude that row.

Exactly the opposite.

Replace [Route?]="Broward" with "Broward"=[Route?].

Wait so I was accidentally setting the value of Route? to equal Broward?

No, you werenโ€™t setting anything; = is a comparison.

[Route?]="Broward" asks, is the Route? column vale the same as the literal text, Broward?

"Broward"=[Route?] asks, is the literal text, Broward the same as the Route? column vale?

The problem is that the = comparison has a quirk: if the value on the left side is blank, the result is TRUE regardless of the value on the right, so youโ€™re best served to put a value you know will not be blank on the left.

Okay Iโ€™m also going to eliminate the blank spaces in the backend and let you know if it works Thank you so much

Hello AppSheet,

I updated my code and the backend and the problem persists. Iโ€™m going to email AppSheet Support about it but does anyone have any ideas on how to fix it? Thank you.

Thatโ€™s a key quirk. I need to go check all my expressions with =

Wonder how many = Iโ€™ll find in my app documentation.

661!!!

Top Labels in this Space