Forum Discussion
Data Masked Column Giving Wrong Records In Visual
- 9 months ago
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 { "[email protected]", "[email protected]" }, 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-daxBest Regards,
Tejaswi.
Community Support
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.
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 { "[email protected]", "[email protected]" }, 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