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 335
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