Interested in learning how to set up row level security (RLS) in Power BI when you have varied criteria? In this post I’ll walk through a scenario of setting up dynamic row level security in which your users have unique access needs. In other words, one user has access to the Northeast and Midwest regions, another has access to the Southeast, and two others overlap with access to the South and Northwest regions.
In my demo (please check out my video for a detailed view and the code used) I have 4 tables, users, user regions, regions, and sales. These tables are connected in various ways such as the users table connected to a many to many or bridge table, users and regions connected, and the regions table connected to the sales table.
What I want to do is apply a filter or row level security to the users table, or to use information from the users table and pass that all the way down to the regions table. Because this is a many to many relationship, I can’t do this just by saying who is logged in.
One way to do this is to create bi-directional relationships but that introduces other problems, so it may not be accessible for your specific case. I’m going walk you through doing this using DAX. I’ve already built the measures, so what I’ll show you is how to build this DAX expression from the pieces that comprise it.
Step 1: Retrieve User ID from Users Table
Step 2: Filter User Region Table Based on User ID
Step 3: Select Columns of Region ID from Table Returned in Step 2
Step 4: Set Up Role That Filters the Region Table Using All Region IDs Identified in Step 3
This will work effectively across any organization structure, as long as the table is organized accordingly. It’s an easy way to get information from our users table, pass it over a many to many relationship and introduce it to our sales table by using that IN operator and the select columns and filter combination.
If you’d like to learn more about using row level security or about incorporating Power BI in your organization, our Power BI experts are here to help. Data and the cloud is what we’re all about and we are here to help with any Azure product or service.
Our experts can help you use your data to grow your business, whether you work on premise, in the cloud or a hybrid approach. Contact us to start a conversation or click the link below. Let us help you take your business from good to great.