Unable to set RLS in Power BI based on another table

19 Views Asked by At

I have the following two tables relevant to RLS:

DIM_EMPLOYEE (EMAIL, BRANCH_ID)

and

DIM_BRANCH (BRANCH_ID)

There is a one-to-many relationship from DIM_BRANCH to DIM_EMPLOYEE (i.e. filters cascade from DIM_BRANCH to DIM_EMPLOYEE). There are also other tables which are filtered by DIM_BRANCH however those are not relevant here.

I am trying to configure RLS so that the DIM_BRANCH table is filtered using current user's email. This should further propagate the filters to all related tables down the stream.

This is the code that I am trying to use in RLS DAX:

DIM_BRANCH[BRANCH_ID] IN 
CALCULATETABLE(
    DIM_EMPLOYEE,
    FILTER(
        DIM_EMPLOYEE,
        DIM_EMPLOYEE[EMAIL] = USERPRINCIPALNAME()
    ),
    VALUES(DIM_EMPLOYEE[BRANCH_ID])
)

However it gives me this error:

A single value for column 'EMAIL' in table 'DIM_EMPLOYEE' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

I have also tried to replace VALUES with MAX without any success. My understanding is that it should work because I am using IN clause which shouldn't have a problem even with multiple rows. What part am I doing wrong here? TIA

0

There are 0 best solutions below