Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
olimilo
Responsive Resident
Responsive Resident

Masking names based on RLS/current user

Let's say I have a table of external users from different clients:

 

NameEmailClient
David Tennantdavid.tennant@who.comTen
Matt Smithmatt.smith@who.comEleven
Peter Capaldipeter.capaldi@who.comTwelve
Jodie Whittakerjodie.whittaker@who.comThirteen

 

If say Matt Smith of Eleven opens the report, how could I transform the following data table to a masked version?

 

ClientScheduledDate
Ten1/1/2018
Eleven1/1/2018
Twelve1/2/2018
Thirteen1/3/2018
Ten1/4/2018
Eleven1/6/2018
Twelve1/4/2018
Thirteen1/4/2018
Ten1/7/2018
Eleven1/8/2018
Twelve1/9/2018
Thirteen1/10/2018

 

Masked client when users from Eleven opens the report:

ClientScheduledDate
Client-11/1/2018
Eleven1/1/2018
Client-21/2/2018
Client-31/3/2018
Client-11/4/2018
Eleven1/6/2018
Client-21/4/2018
Client-31/4/2018
Client-11/7/2018
Eleven1/8/2018
Client-21/9/2018
Client-31/10/2018

 

I tried using USERPRINCIPALNAME in a calculated column but I'm getting an error that I can't use it in a calculated column.

 

Client (e) = IF([Client] <> [UserOrg], "Other Clients", [UserOrg])

Any ideas how to do this? Thanks.

 

Edit: I'm using an Excel file as a source for all datasets. I'm not sure if SQL Dynamic Data Masking can work with this.

1 ACCEPTED SOLUTION
quentin_vigne
Solution Sage
Solution Sage

Hi @olimilo

 

What you could do is add a role "Client" in the Row Level Security

 

and in the area where you can type just add : [Email]=USERPINCIPALNAME() (It will work while consulting the report on app.powerbi.com)

 

And filter all of your table with this conditions, should work

 

EDIT : Didn't see the last table.

You probably need to add an alias to your Client table like "Client-1" etc... and theses aliases will only be displayed when another client is connected to the report, so your first column would look like that : 

-- IF([Email]=USERPRINCIPALNAME() ; Client ; Alias)

 

- Quentin

 

View solution in original post

5 REPLIES 5
quentin_vigne
Solution Sage
Solution Sage

Hi @olimilo

 

What you could do is add a role "Client" in the Row Level Security

 

and in the area where you can type just add : [Email]=USERPINCIPALNAME() (It will work while consulting the report on app.powerbi.com)

 

And filter all of your table with this conditions, should work

 

EDIT : Didn't see the last table.

You probably need to add an alias to your Client table like "Client-1" etc... and theses aliases will only be displayed when another client is connected to the report, so your first column would look like that : 

-- IF([Email]=USERPRINCIPALNAME() ; Client ; Alias)

 

- Quentin

 

Anonymous
Not applicable

How is that meant to be implemented? USERPRINCIPALNAME() can not be used in a calculated column, which is what i thought I would do, to determine whether to show a customer code or an Alias.

 

Anyone can share light on what am i missing here , around that solution ?

You can't use it in a calculated column because it is calculated, it is not dynamic like DAX is.

The calculated column gets it's value when the model is loaded.
DAX values are dynamically built on the moment they are being displayed.

Anonymous
Not applicable

Can you please elaborate on the solution?

 

I've currently set up role based security with 2 levels - 

1) a management level which should see all data, unmasked

2) a user level who sees masked data, with the exception of their own.

Anonymous
Not applicable

Hi, were youable to solve this to display unmasked data for certain users?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors