Power BI — RLS, part 1

There are two basic approaches of implementing Row Level Security in Power BI. This post shows how to implement basic RLS.
We will be working on a simple model example. Two tables: Posts (Fact) and PostTypes (Dimension).

First approach, you can implement RLS directly in Power BI.
- Pick Manage Roles button on the ribbon,
- Create a new role,
- Select a table and column which you want to filter - PostTypes[Id] in this case,
- Write DAX statement, it is our filter definition,

I have created four roles for better understanding:
- PostType Question: [Id] = 1, user is able to see only post which PostType Id is equal 1,
- PostType Answer: [Id] = 2, like above, but Id equals 2,
- PostType Wiki: [Id] in {4,5}, Id equals 4 or 5,
- PostType All: True(), user is able to see all the data.
Select View as and choose a role…

…the data is filtered.

Now, we can upload report to Power BI service.
Pick Dataset’s Security.

And add users to suitable groups.

After the report is shared with users. You can log in as Adam Orlowski. User is able to work on data allowed for PostType Answer Role.

As you see it is basic approach. If your company hires a lot of people there more elastic way is needed.