Show_If lookup USEREMAIL() in two columns

I have two columns (“Code” & “Digit”) referencing the same table (“Users”) and using the same label (“Code”, a unique 3-digit # for each user)–simply, duplicate columns with different names. I want to restrict users from viewing each row based on their email so I’ve used the following as the Show_If expression:

IN(LOOKUP(USEREMAIL(), “Users”, “Email”, “Role”), LIST(“Mentor”))

The Mentor’s three-digit # can be in either Column “Code“ or Column “Digit” (but not in both columns for the same/single row). Using the IN() expression above, each Mentor can see all rows when their # is in Column “Code”, but can’t see the rows where their # is in Column “Digit”.

Is there a way to modify the expression to show all rows pertinent to each Mentor without adding a column named “Digit” to the “Users” table? Or what is the simplest and/or most efficient way to modify the expression to achieve such?

Thank you in advance to taking the time to respond.

1 Like

Is your goal to show a row when the Code value belongs to the user OR when the user is a mentor?

1 Like

Hmm… I would have presumed those two options give the same output because the users’ Role will always be Mentor regardless of whether their Code value goes into Column “Code” or Column “Digit”. But “when the Code value belongs to the user” sounds like the wider net…

Your goal is still a little bit mystery if all your users are Mentors. You need to explain little bit deeper :slight_smile:

2 Likes

To clarify, there are two types of users for this app, one with the role of “Mentor” and the other with the role of “Admin”. I have a view (“Reservations”) of a table (“Calendar”) which has the two ref columns “Code” & “Digit” that refs table “Users”. When a user with the role “Mentor” sees the view “Reservations”, I’d like them to see all the rows that have their code value in either column “Code” or column “Digit”. So far, the Show_If expression only shows the rows with the code value in column “Code”. For visualization purposes:

Row # Code Digit Date & Time
1 123 300 1/1/2026
2 400 123 2/1/2026
3 123 700 3/1/2026

So, currently, user with role “Mentor” and code 123 can see rows 1 & 3, but not 2. I want that user to see all 3 rows.

Hmmmm, I think I understand what is being asked. I would try something like this:

  1. Create a current_user slice. This is a slice on the user table that filters out a users data by email and makes further expressions easier

slice expression: USEREMAIL() = [email]

  1. use a slice to filter out the reservations table with the following expression:

IN( any(current_user[id]), OR([_thisrow].[code], [_thisrow].[digit]))

The above expression says: Is the current users id in either the ‘code’ column or the ‘digit’ column? If yes, include this row in the slice

  1. set the view to be based on the slice created in step 2

Let me know if you have any questions!

2 Likes

When using the slice above, the expression needs to be

IN(ANY(current_user[id]), LIST([code], [digit]))

You probably need to handle the Admin as well. If that role needs to see everything, then you need to wrap the above in

OR(ANY(current_user[role])=”Admin”,IN(..))

2 Likes

@QREW_Apps @AleksiAlkio Thank you both for the suggestions and taking your time to reply. I ended up restructuring the app a bit to use a VC to track the user logged in and based my security filters off of that info.

1 Like