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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
flyinggnugget
Frequent Visitor

Dynamic Masking of Column Values

Hi all, was wondering if anyone might be able to help with the problem that I might be facing with trying to perform some kind of dynamic masking of names. Suppose I have a list of student names and their scores as such:

 

NameScoreSchool

Jason

98A

Mary

41A
Andy67A
Sally93B
Eugene54B

 

I then want to have a slicer to be able to select whether I want to mask the names or not. This slicer will have the options "Masked" and "Unmasked". If "Unmasked" is selected, my chart will show all the names as it is and their respective scores. However, if "Masked" is selected, there will be another slicer to select a name that I want to show. For example, I have already selected "Masked" in the first slicer, and in the second slicer, I selected "Andy", then in the visual, Andy's name will show as Andy, but the rest of the students will show as "Student 1", "Student 2" , etc.

 

I am trying to perform this masking in a dynamic way as I am trying to prevent users from figuring out who the students might be. Suppose I have selected "Masked" and "Jason", and in my visual I have the values sorted in descending order, then the first bar will show "Jason" with a score of 98. In the second bar it should show "Student 1" in place of Sally with a score of 93, third bar "Student 2" in place of Andy with a score of 67.

 

If anyone has any idea on how to approach this, your help will be greatly appreciated. Feel free to create tables or add additional columns if needed. Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @flyinggnugget ,

Please try this way:
Here is my sample data:

vjunyantmsft_0-1728367717244.png

vjunyantmsft_1-1728367778399.png


Use this DAX to create a calculated table for slicer2:

Slicer2 = VALUES('Table'[Name])

vjunyantmsft_2-1728367887759.png


There is no relationship between three tables:

vjunyantmsft_3-1728367915200.png


Use this DAX to create a measure:

DisplayName = 
IF (
    SELECTEDVALUE(Slicer1[Slicer1]) = "Masked",
    IF (
        MAX('Table'[Name]) = SELECTEDVALUE('Slicer2'[Name]),
        MAX('Table'[Name]),
        "Student " & RANKX(FILTER(ALL('Table'), 'Table'[Name] <> SELECTEDVALUE(Slicer2[Name])), 'Table'[Score], SUM('Table'[Score]), DESC, Dense)
    ),
    MAX('Table'[Name])
)

And put the DisplayName and other fields into the table visual:

vjunyantmsft_4-1728368735682.png

Then use this DAX to create another measure for filter:

Filter = 
IF(
    SELECTEDVALUE(Slicer1[Slicer1]) = "Unmasked",
    IF(
        MAX('Table'[Name]) IN  VALUES(Slicer2[Name]),
        1,
        0
    ),
    1
)

Set it up as shown in the following figure:

vjunyantmsft_5-1728369046340.png

vjunyantmsft_6-1728369070267.png


Final output:

vjunyantmsft_7-1728369133590.png

vjunyantmsft_8-1728369199108.png

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @flyinggnugget ,

Please try this way:
Here is my sample data:

vjunyantmsft_0-1728367717244.png

vjunyantmsft_1-1728367778399.png


Use this DAX to create a calculated table for slicer2:

Slicer2 = VALUES('Table'[Name])

vjunyantmsft_2-1728367887759.png


There is no relationship between three tables:

vjunyantmsft_3-1728367915200.png


Use this DAX to create a measure:

DisplayName = 
IF (
    SELECTEDVALUE(Slicer1[Slicer1]) = "Masked",
    IF (
        MAX('Table'[Name]) = SELECTEDVALUE('Slicer2'[Name]),
        MAX('Table'[Name]),
        "Student " & RANKX(FILTER(ALL('Table'), 'Table'[Name] <> SELECTEDVALUE(Slicer2[Name])), 'Table'[Score], SUM('Table'[Score]), DESC, Dense)
    ),
    MAX('Table'[Name])
)

And put the DisplayName and other fields into the table visual:

vjunyantmsft_4-1728368735682.png

Then use this DAX to create another measure for filter:

Filter = 
IF(
    SELECTEDVALUE(Slicer1[Slicer1]) = "Unmasked",
    IF(
        MAX('Table'[Name]) IN  VALUES(Slicer2[Name]),
        1,
        0
    ),
    1
)

Set it up as shown in the following figure:

vjunyantmsft_5-1728369046340.png

vjunyantmsft_6-1728369070267.png


Final output:

vjunyantmsft_7-1728369133590.png

vjunyantmsft_8-1728369199108.png

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

A slicer is the wrong approach.  You need to use separate reports, or hide the "unmasked"  copy of the table

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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