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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Koritala
Helper IV
Helper IV

Data Masked Column Giving Wrong Records In Visual

Hi All,
In my report I have a slicers like employersname and Members slicers along with date range slicer. Members slicer will show the coressponding members for the selected Employersname slicer.
I created a measure with the attached logic for my required columns data masking. The issue is when I drop the firstname masked cloumn which I created, that is not filtering the visaul data as per the employername and Members slicers values selection. For example for X employer there are 2 Members. But when I place the newly created Firstname masked column, it pulling all the records from the backend with out considering the slicers passed values. it seems like mentioned logic is applying masking on every record by scanning the entire table.

Can you please suggest how to proceed in this scenario to show the visual data accroding to slicer values selections with data masking for the required fileds in the layout.

Koritala_0-1760615112546.jpeg

 

Thanks,

Sri.

8 REPLIES 8
DataNinja777
Super User
Super User

Hi @Koritala ,

 

It appears that your filtering is not working in the intended way.  I have created a pbix file to demonstrate the case. 

DataNinja777_0-1760626606904.png

 

FirstName Masked (Broken) = 
VAR vFirstName =
    CALCULATE (
        MAXX ( VALUES ( 'Members'[FirstName] ), 'Members'[FirstName] ),
        ALL ( 'Members' )
    )
RETURN
IF ( NOT ISBLANK ( vFirstName ), REPT ( "*", LEN ( vFirstName ) ), BLANK () )

Filtering will work properly by using the following measure:

FirstName Masked (Working) = 
VAR vFirstName =
    MAXX ( VALUES ( 'Members'[FirstName] ), 'Members'[FirstName] )
RETURN
IF (
    [Can See PII],
    vFirstName,
    IF ( NOT ISBLANK ( vFirstName ), REPT ("*", LEN ( vFirstName ) ), BLANK () )
)

 

DataNinja777_1-1760626693136.png

 

When the filtering is fixed, the crossjoining of the masking will disappear as shown above.

 

I am attaching the pbix file for your reference.

 

Best regards,

 

 

 

 

Hi DataNinja777,

In continoution to my previous message, I have a users table with columns like "Email", "PIIUser(Y/N)".
In this case, if I wan to follow your below user validation, Can you send me the exact logic please? Because it should be dynamically work based on user login id. 

Please let me know if need any further details.

Can See PII =
IF(
    USERPRINCIPALNAME() IN { "pii@demo.com" },
    TRUE(),
    FALSE()
)
 
Thanks,
Sri

Hi @Koritala ,

 

Awesome, thanks for confirming you’re working with a single view and no joins that definitely keeps things simple. In the example DataNinja777 shared, they just used a static email to show how the masking works, but you can totally make it dynamic with the USERPRINCIPALNAME function so it updates automatically for whoever’s logged in.

 

Here’s how you can set up your Can See PII measure:

Can See PII = IF( USERPRINCIPALNAME() IN { "user1@yourdomain.com", "user2@yourdomain.com" }, TRUE(), FALSE() )

 

This checks if the signed-in user is one of the people allowed to view unmasked data. Just swap out those emails for the real ones in your org. Once you’ve got that, you can plug it into your masking logic like you did in your test:

FirstName Masked = VAR vFirstName = MAXX( VALUES( 'YourView'[FirstName] ), 'YourView'[FirstName] ) RETURN IF( [Can See PII], vFirstName, IF( NOT ISBLANK(vFirstName), REPT("*", LEN(vFirstName)), BLANK() ) )

Since you’re only using one view, your slicers will filter everything automatically, so you don’t need to mess with relationships or TREATAS. The masking will just work with your slicers and whoever’s logged in.

 

If you want more details, check out the Microsoft docs:
USERPRINCIPALNAME – https://learn.microsoft.com/en-us/dax/userprincipalname-function-dax
SELECTEDVALUE – https://learn.microsoft.com/en-us/dax/selectedvalue-function-dax
TREATAS – https://learn.microsoft.com/en-us/dax/treatas-function-dax

Best Regards,
Tejaswi.
Community Support


Hi @Koritala ,


I wanted to follow up and see if you had a chance to review the information shared. If you have any further questions or need additional assistance, feel free to reach out.

 

Thank you.

Hi @Koritala ,

 

Just wanted to check if you had the opportunity to review the suggestion provided?

Thank you.

 

Hi DataNinja777,

Thanks for sharing pbxi.

One thing I want to tell you that in my case, I have only one view where all my report columns are coming. There are no multiple tables or joins.

Also, can you please confirm me, you have made static user id { "pii@demo.com" }. In my case how to write the expression exactly?

Can See PII =
IF(
    USERPRINCIPALNAME() IN { "pii@demo.com" },
    TRUE(),
    FALSE()
)

 

Thanks,

Sri.

AnalyticPulse
Super User
Super User

hi @Koritala 
it appears that your measure dont have a proper filter context relationship to your slicers, you can try using calculated column  for this purpose, otherwise you have to apply filter context in your measure properly.

My Work:
Analytic Pulse Blog  
Sharing data & BI insights


Docynx Productivity Tools  
Tools to simplify workflow


Hi,

Thanks for your response.

We can't create as calculated column insteated of measure as we are using userprincipalname function in logic.

Thanks,

Sri

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors