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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
olimilo
Post Prodigy
Post Prodigy

Masking names based on RLS/current user

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

 

NameEmailClient
David Tennant[email protected]Ten
Matt Smith[email protected]Eleven
Peter Capaldi[email protected]Twelve
Jodie Whittaker[email protected]Thirteen

 

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors