Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Dynamic RLS: propagate to non-security dimensions

Hi. I have been struggling finding a good solution to a very common RLS-problem for awhile. I will try to explain it here with a simple example:

 

My data model contains the following tables:

 

Dimensions:

UserBridge (RLS) 

Company

Department

Project

 

Facts:

Sales

Budget

 

First I create a relation in the data model *:1 from UserBridge to Company setting the filter direction to both and apply security filter in both directions. UserBridge contains every valid combination between UserID and CompanyID. Then I relate Company to Sales and to Budget 1:*. Now I go through the RLS setup role etc. with filter on USERPRINCIPALNAME(). Then I relate the last two dimensions Project and Department to both Budget and Sales 1:*.

 

The security works perfectly, but when I create a slicer and view as user 1 (who can only see a subset of companies through RLS), I still see all projects and all departments, even though some of them does not exist for the user 1's companies. Now I know perfectly why this is happening, and it is not even a security breach, as it is only for convenience of the single user, that I want to only show a subset of departments/projects.

 

I tried to change all the relations between Department and Project to filter in both directions, which would technically solve the problem, but is not a best practice solution. Furthermore this workaround quickly rasies ambiguity issues in the model, when having more than 1 fact tables/ related dimensions.

 

Next I could try to contain Department and Project in the Company table, making the company table explode, as the same department can exist in multiple companies, same being the case for Projects.

 

Last option I can think of is using the department and project fields directly from the Budget and Sales fact tables, but this is not good practice either, as I would have to filter two slicers every time I need to select a department/project.

 

I suppose this is a fairly common case / data model, so what am I missing here? I am not looking for more workarounds, but rather what is the best practice here.

 

Thanks.

 

/Rasmus   

  • Anonymous's avatar
    Anonymous
    5 years ago

    The answer was very simple after all... This piece of beauty did the trick:

     

    [CustomerID] =
    CALCULATE (
    MAX ( User[CustomerID] ),
    FILTER ( User, User[UserEmail] = USERPRINCIPALNAME () )
    )

     

    This code needs to be applied to all Dimensions in my security role for which I only want to see lines relevant to Customer XXX

     

    Hope this can help others too. 

7 Replies