How to Expressions

data
expressions
(Wanderson Guilherme De Moura Oliveira) #1

Hi, I would like to compare a specific value of a column with another value in another table. Can someone help me? For example: I have a Consultants table [Company name] and another table of sales [Company], I would like to know if the column Consultants [company name] value is equal to the value of the [Company] column, analyzing by lines for the time being I can check by list !
I am currently using the following expression: IN (Sales [Company], Sellers [Company Name]).

(Steve Coile) #2

Your expression is close. Try this instead:

IN ([Company], Sellers [Company Name])

When you include both a table name and column name, as with Sales [Company], AppSheet replaces that with a list of all values from that column of that table. With the IN() function, the first argument should be a single value, not a list.

In the example I provided, I’ve replaced your column list reference with a column reference, [Company]. AppSheet will replace a column reference with value from that column in the current row.

1 Like
(Wanderson Guilherme De Moura Oliveira) #3

Okay, but I want it if the result returns true when showing in a slice only the rows in which the [Company] value is the same as the [Company Name] sellers, this function I used, but checks to see if it contains the value in the list, if yes, show all data, even other lines that do not contain the value of the seller [Company name]

(Steve Coile) #4

How does the app user select the company they want the slice limited to? A common method is to provide the user an option in user settings. The user’s choice can then be referenced in an expression–such as the slice’s filter expression–to affect app behavior based on the user’s setting.

Suppose you created a user setting called Company. You could reference that value in you slice filter expression as such:

IN (USERSETTINGS("Company"), Sellers [Company Name])

1 Like