ELSEIF with 2 two options in THEN

Is it at all possible to do an if then statement but have 2 options on the Then side? I'm implementing some management chain hierarchy controls for a dashboard and I want to give assistants the option to see their leaders orgs as well. Some assistants span multiple orgs (like Ali who supports two people). The idea, is that you "trick" tableau into thinking the user logged in is actually a different user.

What I'm trying is something like:

if [prefullname]='Liz' then 'Bob' Elseif [prefullname] = 'Ali' then 'Rich or Karl' elseif [prefullname] = 'Brian' then 'Jim' End

2 answers

  • answered 2019-03-14 04:00 Daniel Sims

    The best way to handle access permissioning is through user filters. This article gives a good example of their use.

    Essentially, each user can be given very specific high level filters (Such as Ali being able to see only Rich and Karl.) This method allows for fine tuning in Tableau Desktop and the permissioning persists after publishing to Tableau Server. It is a very secure method.

    Otherwise, unfortunately, the dual condition IF THEN statement as written is not possible. The only alternative is to somehow alter/add to the underlying relational data to reflect the needs of the access. (ie: a field which lists [Assistant])

    I hope this helps!

  • answered 2019-03-14 04:11 rocksteady

    I would second Daniel's approach above - this really isn't the way to manage permissions, especially if the data is confidential or sensitive. But if you must make your example work as stated, it could look something like this.

    First, define each 'access_list' variable as you did above:

    if [prefullname]='Liz' then 'Bob' 
        elseif [prefullname] = 'Ali' then 'Rich, Karl'
        elseif [prefullname] = 'Brian' then 'Jim'

    And then you could check a 'has_access' condition for permission-matching for each person.

    IF CONTAINS([access_list], [prefullname]) THEN TRUE
        ELSE FALSE

    I don't quite know the data structure here, or how you're filtering permissions, but the idea would be to define an array of names for each person, then check - for each user - which of the names was or wasn't present.