tableau-desktop

hiding part of text or string characters


I need to hide part of full name characters in tableau. Is it possible to achieve is as below;

[FullName] :Surname, FirstName MiddleName

SuXXXXe, FiXXXXXXe MiXXXXXXXe


Solution

  • It is achievable using the Left, Replace, Space and Right String Functions of Tableau.

    LEFT([string field],2) + REPLACE(SPACE(LEN(string field)-3), " ", "x") + RIGHT([string field],1)

    What the above function does is, if string field is "Revanth" then the left function gives me the first 2 letters of the string field, i.e, 'Re' and the Right function gives me the last letter of the string field 'h' and Space Function takes an argument in integer N where it generates " " N times, and we replace " " by 'x' to satisfy your criteria.

    Link for the string function documentation of tableau: https://help.tableau.com/current/pro/desktop/en-us/functions_functions_string.htm#replace

    LEFT(string,2) + REPLACE(SPACE(LEN(SPLIT(string,",",1))-3),"X")+ RIGHT(SPLIT(string,",",1),1) + "," + LEFT(SPLIT(SPLIT(string,",",2)," ",1),2) + REPLACE(SPACE(LEN(SPLIT(SPLIT(string,",",2)," ",1)-3)," ","X") + RIGHT(SPLIT(SPLIT(string,",",2)," ",1),1)+" "+LEFT(SPLIT(SPLIT(string,",",2)," ",2),2)+REPLACE(SPACE(LEN(SPLIT(SPLIT(string,",",2)," ",2)-3)," ","X") + RIGHT(SPLIT(SPLIT(string,",",2)," ",2),1)