Forum Discussion

OneWithQuestion's avatar
OneWithQuestion
Post Prodigy
8 years ago

RLS on Direct Query to SQL: Want to filter one table with the username contained in the other?

I have two tables on SQL server that I am connecting to through PBI using Direct Query.

 

The first table is a list of users (what is returned by username() function) and that table has a departmentID.

 

If a user has access to three departments then they would have three entries: UserBob, Dept1, UserBob, Dept2, UserBob, Dept3 for example.

 

The second table contains a column for DepartmentID and another column for DepartmentName.

 

I would like to set this up so that users only get rows back from the department table when their username() has entries that match DepartmentID in the department table.

 

 

I can do this in a Tabular model by setting a filter on the the usertable where username=username() and then doing a lookup function in the second table to tie deptIDs back.

 

However, I cannot seem to get the two tables to filter eachother.

 

How can I leverage row security so that the first table has entries for the user and what departmentIDs they can see and then filter the second table by that?

 

Thanks!

2 Replies