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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
ryanem
New Member

Anonymizing certain data / Dynamic data masking

Hello and thank you in advance for reading. I'm trying to share performance data with team members. I can create a bar chart with Names on the Y axis and then the Performance Metric on the X axis, however I would like each person to be blinded to the names of the other teammates (yet still see the individual performance metric value of each one of those anonymous colleagues).

I've spent a couple hours trying to do this with copilot/chatgpt but have been unsuccessful. 

 

First I did RLS, but this ended up just filtering for the individual's data and they can't see anyone elses.

 

Then there was an attempt by creating a calculated column -- unsuccessful because USERPRINCIPALNAME() can't be used in a column. Then there was an attempt by creating a DAX measure -- unsuccessful.  Then there was an attempt by using the 'Deneb' visual add-in -- unsuccessful. 


I thought maybe if I had a separate Excel tab for each teammate which had all of the data, their name, and then everyone else's name as "anonymous" I might be able to do something (almost like a custom report for each person), but that doesn't seem to get me anywhere--I can't figure out how to automatically generate a report for each person.

I'm open to any advice. Thank you so much!!!

4 REPLIES 4
v-karpurapud
Community Support
Community Support

Hi @ryanem 

I wanted to check if you’ve had a chance to review the information provided. If you have any further questions, please let us know. Has your issue been resolved? If not, please share more details so we can assist you further.

Thank You.

v-karpurapud
Community Support
Community Support

Hi @ryanem 

Thank you for submitting your question to the Microsoft Fabric Community Forum, and thanks to @Royel and @danextian  for offering helpful suggestions.

 

Could you let us know if the suggested solution resolved your issue? This information can assist other community members facing similar challenges.

Thank you.

danextian
Super User
Super User

Hi @Royel 

You can follow @Royel’s approach if the goal is to mask data in a table or matrix visual. However, when the masked data must function as a dimension, you’ll need a more creative method. This would involve creating a table that contains all possible combinations of the current user’s email with the emails of other users. If the two email columns from this crossjoin match, return the actual username; otherwise, return something like Employee xxxx - the rows to return depend on the logged in user.

danextian_0-1754978205097.gif

The attached PBIX file contains two approaches. In my testing, the disconnected table method performs faster, though actual results may vary depending on your semantic model.

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Royel
Responsive Resident
Responsive Resident

Hi @ryanem thank you posting this interesting problem. 

Lets try to achieve this with help of Power Query and Dax

 

Here is sample data: Update your email address 

EmployeeIDNameEmailPerformance ScoreDepartment
1Royelmyemail@domain.io85Sales
2Sarah other@domain.io92Sales
3Mike other1@domain.io78Sales
4Lisa other2@domain.io88Sales

 

Save this data into a csv file and the go to power query create a blank query and pest this m-code 

let
    // Step 1: Load your source data
    Source = Csv.Document(
        File.Contents("D:\Community\Dynamic Data Masking\Employee_Performance_Data.csv"),
        [Delimiter=",", Columns=5, Encoding=1252, QuoteStyle=QuoteStyle.None]
    ),
    
    // Step 2: Promote headers and set data types (FIXED: was EmployeeData, now Source)
    PromotedHeaders = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    ChangedType = Table.TransformColumnTypes(PromotedHeaders,{
        {"EmployeeID", Int64.Type}, 
        {"Name", type text}, 
        {"Email", type text}, 
        {"Performance Score", Int64.Type}, 
        {"Department", type text}
    }),
    
    // Step 3: Add Index column starting from 1
    AddedIndex = Table.AddIndexColumn(ChangedType, "Index", 1, 1, Int64.Type),
    
    // Step 4: Create anonymous name pattern
    AddedAnonymousName = Table.AddColumn(AddedIndex, "Anonymous Name", 
        each "Employee " & Text.From([Index]), type text),
    
    // Step 5: Create department-based anonymous names (optional)
    AddedDeptAnonymous = Table.AddColumn(AddedAnonymousName, "Dept Anonymous Name", 
        each [Department] & " Employee " & Text.From([Index]), type text),
    
    // Step 6: Create consistent sorting order (important for anonymization)
    SortedData = Table.Sort(AddedDeptAnonymous,{{"EmployeeID", Order.Ascending}}),
    
    // Step 7: KEEP ALL COLUMNS for DAX solution (don't remove Name and Email)
    // We need Name and Email for USERPRINCIPALNAME() logic in DAX
    FinalColumns = Table.SelectColumns(SortedData,{
        "EmployeeID", 
        "Name", 
        "Email", 
        "Anonymous Name", 
        "Dept Anonymous Name",
        "Performance Score", 
        "Department"
    })
in
    FinalColumns

Note: You need to update the source 

 

Now, Lets write a dax to get the Display Name not users name or email address 

Dax Measure: 

Display Name = 
VAR CurrentUser = USERPRINCIPALNAME()
VAR SelectedEmail = SELECTEDVALUE(EmployeeData[Email])
VAR ActualName = SELECTEDVALUE(EmployeeData[Name])
VAR AnonymousName = SELECTEDVALUE(EmployeeData[Anonymous Name])
RETURN
IF(
    SelectedEmail = CurrentUser,
    ActualName & " (You)",
    AnonymousName
)

 

Create a Table visual: with these columns 

Royel_0-1754958049993.png

As you noticed, its making all users records as Anonymous (Employee 2,3,4) expcept current user (my name). 

 

Find this helpful? ✔ Give a Kudo • Mark as Solution – help others too!

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors