How to Hack RLS to Make RANK() Work on Entire Dataset

Let’s say you are building a dashboard for the Sales team and have the following requirements:

Each sales person should have access to only their territory – Ok this is easy enough. We can achieve this using RLS.

Rank the territories based on revenue. Sales person should be able to view the ranking of their territory – Ranking is straight forward, we can use Rankx function to achieve this. But wait! once RLS is applied, each sales person can view only their data. We need the entire dataset to rank the territories. How to solve this…

You are in luck, I have a video that solves this problem. Enjoy!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s