Before Tableau 9, I was asked to add row-level security to a dashboard I created for work. Although I had never added row-level security to any of my previous dashboards, I knew it was possible. I found a great tutorial on the Tableau community site here. However, this only works if everyone who is viewing your dashboard also has their username in the data. For example, I was building a dashboard for our sales team within the insurance company I work for, where there were 4 levels of data: sales director (RSD) -> sales manager (RSM) -> sales leader (TSL) -> agent. A director is in charge of 4-5 managers, a manager is in charge of 6-7 sales leaders and a sales leader has about 10 agents they keep accountable. Each sales level ID is in our data, so it looks something like this:
POLICY_NUMBER AGENT_NBR RSD_ID RSM_ID TSL_ID
0000000 12345 AAAA BBBB CCCC
I wanted to filter the data such that a sales director is able to see all levels in the hierarchy that are relevant. However, the people within the sales hierarchy are not the only ones who are viewing this data. For example, I want to view the dashboard. I have nothing to do with the sales hierarchy, therefore, I will not be in this data set. So, if I were to do a simple usernamer()=RSD_ID filter, where that calculation equals true, I would never be able to see any data because my ID is not associated with any row in this dataset.
I was able to use table calculations to make this work on one sheet. However, I needed to create a calculation that would allow me to filter across multiple sheets. Luckily, Tableau 9 came out and with that came LEVEL OF DETAIL calculations. To fix this issue, this is what I did:
- Create a calculation to determine what level in the sales hierarchy the user is:
- Create another calculation to determine what the total max value from step 1 (LoD):
- Create a boolean calculation to only keep the data you want your user to view:
Let me know what you think, if you think this is useful or if there’s a better way out there!