Anonymizing Data Using Tableau Prep

You've spent hours building a dashboard for a client, and now you want to show it off in your portfolio or on your Tableau Public page. The catch is that it's built on client data, and your client doesn't want that data public. Does that mean your dashboard will forever remain unseen? Not necessarily, thanks to anonymization.

Anonymization transforms your real data into mock data. It replaces sensitive values (like customer names or Social Security numbers), obscures numbers (like revenue and profit), and scrambles rows, all while keeping the underlying framework intact. With your client's approval, you can anonymize the dataset, relink your dashboard to the mock data, and share it.

In this post, I'll walk you through an introductory process for anonymizing data with Tableau Prep. Before you begin, get your client's approval and confirm which fields they require to be anonymized.

Getting started

Open Tableau Prep. You can use this process to create new tables to export (if you did most of your calculations and joins in Tableau), or add these steps to an existing Prep flow. In this example, I'll use the Superstore dataset that comes with Tableau. Connect to it, bring in the Orders table, and keep only these fields: Order ID, Order Date, Customer Name, Region, and Profit.

Step 1: Anonymize Order ID

Order ID is often used in joins and counts, so we need to maintain its underlying logic and count. To do that, we'll build a lookup table of anonymized IDs.

1) Branch off the original table with an Aggregate step and group by Order ID. This gives us one row per unique Order ID.

2) Add a Clean step. We'll create a new ID for each existing one by ranking the IDs and building the new value from that rank. Click the three dots on the Order ID column, select Create Calculated Field, and select Rank.

3) In the Rank window, name the new field Order Rank and order the IDs alphabetically. (We'll order by a different metric later.)

4) Click Done. Every Order ID now has a unique rank integer.

5) Create a new calculated field named Anon Order ID. Use any naming convention you like, as long as it includes the rank wrapped in STR() so the result is a string. For example: 'ORD-' + STR([Order Rank]) [image] The result is a set of unique IDs that carry none of the original's potentially sensitive information.

6) Drop Order Rank, since we no longer need it, and join this table back to the original with an inner join on Order ID. Then drop the two original Order ID fields.

Your new Order ID field is ready to go.

Step 2: Anonymize Customer Name

We'll repeat the same process for Customer Name. If you want to keep realistic individual names, you can use Mockaroo or an AI chatbot to generate a lookup table of fake names (just don't share the real names with them). For this exercise, we'll work entirely in Tableau Prep and convert each name to a Customer_# format.

1) Branch off the original table with a new Aggregate step and group by Customer Name. This time, also drag Profit onto Aggregated Fields so we can rank by profit instead of alphabetically. This keeps the new IDs from following the original name order, which would make the process easier to figure out.

2) Add a Clean step, click Create Calculated Field on the Customer Name column, and select Rank. This time, change the drop-down next to Rank to Profit.

3) Click Done to get a unique rank for each customer based on profit. Double check that the count of rank values matches your count of customer names (in the unlikely case of a tie). Then create a new calculated field named Anon Customer Name using the rank, such as 'Customer_' + STR([Customer Rank]).

4) Drop the rank field and inner join this table onto the main branch on Customer Name.

5) Drop the original Customer Name fields and keep Anon Customer Name.

Step 3: Anonymize Profit and Order Date

For these two fields, we can simply overwrite the values with a calculated field.

Profit: Add a new Clean step and create a calculated field named Profit. Prep will warn that you're overwriting the existing field, which is what we want. Use any formula that changes the values, such as multiplying or dividing by an arbitrary number. Since this is a currency value, wrap it in ROUND() set to two decimal places, for example ROUND([Profit] * 1.37, 2).

Order Date: Create another calculated field named Order Date. Use DATEADD to add or subtract an arbitrary number of years, months, or days. Wrap it in DATE() if you want a Date field rather than DateTime, for example DATE(DATEADD('month', -18, [Order Date])).

Step 4: Scramble the rows

Each sensitive field is now anonymized, and it's tempting to call it a day here. But one crucial step remains: scrambling the rows to further obscure the original data. To do this, we split the columns apart, order each group randomly, and join them back together in their new order. Scrambling can drastically change how some of your charts look, since it breaks the relationships between columns in the original data. That's fine: the goal is to obscure client data so you can show off your design, not to present real insights.

1) Create three branches, each with its own Clean step.

2) Split the columns across the branches. In our example, Order Date, Region, and Profit go on one branch, Anon Order ID on another, and Anon Customer Name on a third. Remove from each branch the columns that live on the others. If any columns need to keep their order in relation to each other (such as a Start Date and End Date), keep them on the same branch.

3) On each branch, create a calculated field named Random_A (Random_B and Random_C for the others) using RANDOM().

4) Create a second calculated field named Join_Key with this LOD: { ORDERBY [Random_A] ASC : RANK() } [image] This gives each row on the branch a random rank. Once it's created, feel free to drop the Random field.

5) Join the branches back together on Join_Key and verify that the row count matches your original table.

6) Drop the Join_Key fields in a final Clean step.

Wrapping up

You now have a fully anonymized dataset ready to relink your dashboard to. Check whether any parameters need renaming, and test the relinked dashboard in a copy of the original. There are many more avenues to explore in anonymization, not only in the data but also in the dashboard formatting, but I hope this introduction gets you started and encourages you to learn more so you can start showcasing your dashboards.

Author:
Derek Lein
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2026 The Information Lab