Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
can someone please help in writing the PBI DAX query for replacing the first part of the email id with***** and displaying only the domain name of the email id.. example ******@microsoft.com.
I tried the below code but in vain-
Solved! Go to Solution.
Use this
Masked Email = REPLACE([EMail],1,FIND("@",[EMail])-1,REPT("*",FIND("@",[EMail])-1))
You can also use variable and write in DAX short line syntax
Masked Email =
VAR _PositionOfDomain = FIND("@",[EMail])-1
RETURN
REPLACE(
[EMail],
1,
_PositionOfDomain,
REPT("*",_PositionOfDomain
)
)
If you want the number of asterisks to match the first part, then try
Masked =
VAR _Email = SELECTEDVALUE ( Emails[Email] )
VAR _Len = LEN ( _Email )
VAR _Pos = SEARCH ( "@", _Email ) - 1
VAR _Mask = REPT ( "*", _Pos )
RETURN
IF ( _Len > 0, _Mask & RIGHT ( _Email, _Len - _Pos ) )
If you'd prefer an even more anonymous fixed-length mask, then you can simplify it to
Masked =
VAR _Email = SELECTEDVALUE ( Emails[Email] )
VAR _Len = LEN ( _Email )
VAR _Pos = SEARCH ( "@", _Email ) - 1
RETURN
IF ( _Len > 0, "*****" & RIGHT ( _Email, _Len - _Pos ) )
Use this
Masked Email = REPLACE([EMail],1,FIND("@",[EMail])-1,REPT("*",FIND("@",[EMail])-1))
You can also use variable and write in DAX short line syntax
Masked Email =
VAR _PositionOfDomain = FIND("@",[EMail])-1
RETURN
REPLACE(
[EMail],
1,
_PositionOfDomain,
REPT("*",_PositionOfDomain
)
)