How do i mask data in SSRS Expression based on condition i need to mask the first 10 digit of a phone number
Example: Favorites: PBM Phone: 800-555-1111
Favorites: PCS Phone: 800-555-2222
Favorites: OTH Phone: 855-555-3333
Logic: IF FAVORITES=PBM THEN XXX-XXX-1111 ELSEIF IF FAVORITES=PCS THEN XXX-XXX-2222 ELSE 855-555-3333
I can write it in snowflake SQL but can't figure out how to translate in SSRS expression
,case Favorites
when 'PBM' then CONCAT('XXXXXX', RIGHT(Phone,4))
when 'PCS' then CONCAT('XXXXXX', RIGHT(Phone,4))
else Phone end as PhoneNumber
Thanks
The SWITCH function is similar to the CASE where it can have multiple selections. The first argument is the expression follow by the result if true - followed by additional expression and results. The & is used to concatenate text.
=SWITCH(Fields!Favorites.Value = "PBM", "XXXXXX" & RIGHT(Fields!Phone.Value, 4),
Fields!Favorites.Value = "PCS", "XXXXXX" & RIGHT(Fields!Phone.Value, 4),
1 = 1, Fields!Phone.Value
)
But since you only really have two results, you could use an IIF.
=IIF(Fields!Favorites.Value = "PBM" OR Fields!Favorites.Value = "PCS", "XXXXXX" & RIGHT(Fields!Phone.Value, 4), Fields!Phone.Value)