Forum Discussion

Jadegirlify's avatar
Jadegirlify
Helper I
1 year ago
Solved

Need help creating Row Level Security based on the Department Name in the Table

HR Table (HR Report)

Department

Employee ID

Employee

email

Acct

111

A Smith

[email protected]

Acct

222

B Daks

[email protected]

Acct

333

C Mark

[email protected]

Acct

444

D Tim

[email protected]

Acct

555

E Sam

[email protected]

Acct

666

F Jack

[email protected]

Data

150

G Kim

[email protected]

Data

250

H Tom

[email protected]

Data

350

I Boy

[email protected]

Data

450

J May

[email protected]

Data

550

K Leo

[email protected]

Data

650

L Pam

[email protected]

Data

750

M Luke

[email protected]

IT

100

N Kobe

[email protected]

IT

200

O Will

[email protected]

IT

300

P Heal

P[email protected]

IT

400

Q Taz

Q[email protected]

IT

500

R Sun

[email protected]

IT

600

S Craig

[email protected]

IT

700

T Corey

[email protected]

 

Medical Table (Medical Report)

Department

Employee ID

Employee

email

Medical

Acct

111

A Smith

[email protected]

Respiratory

Acct

111

A Smith

[email protected]

TB

Acct

111

A Smith

[email protected]

Chol

Acct

222

B Daks

[email protected]

TB

Acct

333

C Mark

[email protected]

Chol

Acct

444

D Tim

[email protected]

Typ

Acct

555

E Sam

[email protected]

Chol

Acct

666

F Jack

[email protected]

TB

Acct

666

F Jack

[email protected]

Chol

Data

150

G Kim

[email protected]

Chol

Data

250

H Tom

[email protected]

Respiratory

Data

350

I Boy

[email protected]

TB

Data

450

J May

[email protected]

Chol

Data

550

K Leo

[email protected]

Chol

Data

650

L Pam

[email protected]

Typ

Data

750

M Luke

[email protected]

Respiratory

Data

750

M Luke

[email protected]

TB

Data

750

M Luke

[email protected]

Typ

Data

750

M Luke

[email protected]

Chol

IT

100

N Kobe

[email protected]

TB

IT

200

O Will

[email protected]

TB

IT

300

P Heal

P[email protected]

Typ

IT

400

Q Taz

Q[email protected]

Typ

IT

500

R Sun

[email protected]

Typ

IT

600

S Craig

[email protected]

Chol

IT

700

T Corey

[email protected]

Chol

 

Mask Table (Mask Report)

Department

Employee ID

Employee

email

Mask

Acct

111

A Smith

[email protected]

N95

Acct

111

A Smith

[email protected]

Surgical

Acct

111

A Smith

[email protected]

Basic

Acct

222

B Daks

[email protected]

N95

Acct

333

C Mark

[email protected]

Basic

Acct

444

D Tim

[email protected]

Basic

Acct

555

E Sam

[email protected]

Surgical

Acct

666

F Jack

[email protected]

Basic

Acct

666

F Jack

[email protected]

Surgical

Data

150

G Kim

[email protected]

Surgical

Data

250

H Tom

[email protected]

N95

Data

350

I Boy

[email protected]

Surgical

Data

450

J May

[email protected]

Surgical

Data

550

K Leo

[email protected]

Surgical

Data

650

L Pam

[email protected]

Surgical

Data

750

M Luke

[email protected]

Basic

Data

750

M Luke

[email protected]

Surgical

Data

750

M Luke

[email protected]

N95

IT

100

N Kobe

[email protected]

Basic

IT

200

O Will

[email protected]

N95

IT

300

P Heal

P[email protected]

N95

IT

400

Q Taz

Q[email protected]

Surgical

IT

500

R Sun

[email protected]

Basic

IT

600

S Craig

[email protected]

Basic

IT

700

T Corey

[email protected]

Basic

 

  • All Tables were imported from Dataverse
  • How can I set up row level security in powerBi so that each employee can only see data from their respective department in the table. These employee are not members in the workspace. The report will only be published and shared via powerbi online link

     

    1. When “A Smith” in Acct department open/views the HR Report page, he must only see the following record:

    Department

    Employee ID

    Employee

    email

    Acct

    111

    A Smith

    [email protected]

    Acct

    222

    B Daks

    [email protected]

    Acct

    333

    C Mark

    [email protected]

    Acct

    444

    D Tim

    [email protected]

    Acct

    555

    E Sam

    [email protected]

    Acct

    666

    F Jack

    [email protected]

 

  • Hi Jadegirlify ,

     

    For this you would need to have a formula in the department column that would get the department for the current login something similar to:

    var selecteduserdepartment = MAXX(FILTER(Users, Users[email] = USERPRINCIPALNAME()), Users[Department])
    
    RETURN
     Users[Department] = selecteduserdepartment

     

    This will allow you to do the filter you need:

    This need to be applied to the user table:

     

     

    My only question is what do you mean when you say that "These employee are not members in the workspace. The report will only be published and shared via powerbi online link"?

     

    What is the Power BI Online Link? Is it the Share to Web link? that this is not a secure link and RLS will not work on top of it?

     

    RLS only works within the service and can be trough a workspace or giving acces to an app.

     

     

1 Reply

  • Hi Jadegirlify ,

     

    For this you would need to have a formula in the department column that would get the department for the current login something similar to:

    var selecteduserdepartment = MAXX(FILTER(Users, Users[email] = USERPRINCIPALNAME()), Users[Department])
    
    RETURN
     Users[Department] = selecteduserdepartment

     

    This will allow you to do the filter you need:

    This need to be applied to the user table:

     

     

    My only question is what do you mean when you say that "These employee are not members in the workspace. The report will only be published and shared via powerbi online link"?

     

    What is the Power BI Online Link? Is it the Share to Web link? that this is not a secure link and RLS will not work on top of it?

     

    RLS only works within the service and can be trough a workspace or giving acces to an app.