---
# System prepended metadata

title: Untitled

---

## Creating Calculated Columns in Tableau

Creating calculated columns in Tableau allows you to derive new data from existing data in your dataset. This can be particularly useful for tasks such as segmenting data, converting data types, aggregating data, filtering results, and calculating ratios. In this guide, we will focus on creating three specific calculated columns: Frequency, Monetary, and Recency, and then use these columns to perform customer clustering.

### Step-by-Step Guide to Create Calculated Columns

1. **Open the Calculation Editor:**
   - Navigate to a worksheet in Tableau.
   - Select `Analysis` from the menu bar.
   - Choose `Create Calculated Field` to open the Calculation Editor[1][7].

2. **Create the Frequency Column:**
   - In the Calculation Editor, enter a name for the calculated field, such as "Frequency".
   - Enter the formula for calculating frequency. This could be a count of transactions or items purchased by each customer.
   - Click `OK` to save the calculated field.

3. **Create the Monetary Column:**
   - Repeat the steps to open the Calculation Editor.
   - Name the calculated field "Monetary".
   - Enter the formula to calculate the total spend or average transaction value.
   - Click `OK` to save the calculated field.

4. **Create the Recency Column:**
   - Open the Calculation Editor again.
   - Name the calculated field "Recency".
   - Enter the formula to calculate the time since the last transaction.
   - Click `OK` to save the calculated field.

5. **Format the Calculated Fields:**
   - Right-click on the calculated field in the Data pane.
   - Choose `Default Properties` > `Number Format`.
   - Select the appropriate format for each calculated field (e.g., currency, number, date)[4].

### Customer Clustering Using Calculated Columns

1. **Create a View:**
   - Drag the calculated fields you've created onto the view to visualize the data.

2. **Perform Clustering:**
   - Drag `Cluster` from the Analytics pane into the view.
   - Customize the cluster by adding or removing variables, and specify the number of clusters if necessary[3][15].

3. **Edit Clusters:**
   - Right-click on the Clusters group on the Color shelf to edit or describe the clusters.
   - Customize the cluster results by adding or removing fields, and changing the number of clusters[3].

4. **Use Clusters in Analysis:**
   - Apply the clusters to your analysis by using them to color marks, filter the view, or create sets for segmentation[15].

5. **Save and Rename Clusters:**
   - To rename or save the clusters for future use, create a group from the cluster results[3].

By following these steps, undergraduate students should be able to create calculated columns in Tableau and use them for customer clustering effectively. Remember to always check the calculations for accuracy and ensure that the data is formatted correctly for the analysis you intend to perform.

Citations:
[1] https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_create.htm
[2] https://hevodata.com/learn/setting-up-rfm-analysis-in-tableau/
[3] https://help.tableau.com/current/pro/desktop/en-us/clustering.htm
[4] https://help.tableau.com/current/pro/desktop/en-us/calcs_add_calculated_column.htm
[5] https://community.tableau.com/s/question/0D54T00000C64WESAZ/create-rfm-segmentation
[6] https://playfairdata.com/how-to-do-customer-segmentation-with-dynamic-clustering-in-tableau/
[7] https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_formulas.htm
[8] https://www.phdata.io/blog/how-to-create-custom-categories-in-tableau-rfm-analysis/
[9] https://www.youtube.com/watch?v=U56hgTGJr5o
[10] https://www.youtube.com/watch?v=hB8Pbj870nI
[11] https://www.optimussbr.com/rfm-analysis-in-tableau/
[12] https://www.youtube.com/watch?v=d5O48p2oMGs
[13] https://hevodata.com/learn/tableau-calculated-fields/
[14] https://public.tableau.com/views/TableauSuperstoreRFMAnalysis_0/TableauSuperstoreRFMAnalysis?%3Adisplay_count=y&%3Adisplay_static_image=y&%3Aembed=y&%3AshowTabs=y&%3AshowVizHome=no
[15] https://evolytics.com/blog/make-cluster-analysis-tableau-10/
[16] https://www.datacamp.com/tutorial/calculalting-fields-tableau-tutorial
[17] https://www.firmai.org/documents/RFM%20Analysis/
[18] https://www.datacamp.com/tutorial/cluster-analysis-in-tableau
[19] https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields.htm
[20] https://www.shiksha.com/online-courses/articles/calculated-field-in-tableau/

To improve clarity and understanding, especially for undergraduate students, here's a refined version of the instruction for using the FIXED function to calculate the distinct count of "Sale Date" for each "Customer ID", with the goal of creating the Frequency Column:

### Improved Instruction:

In this example, our objective is to accurately measure the frequency of purchases made by each customer. To achieve this, we will utilize the FIXED Level of Detail (LOD) expression in Tableau, combined with the COUNTD function. The FIXED LOD expression allows us to perform calculations at a specific level of granularity, regardless of the dimensions present in the view. This is particularly useful for our goal, as it enables us to calculate metrics for each "Customer ID" independently of other dimensions.

Here's how to create the Frequency Column using the FIXED function to calculate the distinct count of "Sale Date" for each "Customer ID":

1. **Open the Calculated Field Editor:**
   - Right-click in the Data pane and select `Create Calculated Field` to open the editor.

2. **Enter the Calculated Field Name:**
   - Name your calculated field something descriptive, such as "Frequency".

3. **Construct the Calculation:**
   - In the formula area, enter the following LOD expression:
     ```
     {FIXED [Customer ID]: COUNTD([Sale Date])}
     ```
   - This formula instructs Tableau to calculate the distinct count of "Sale Date" for each unique "Customer ID". The COUNTD function ensures that each sale date is counted only once per customer, providing a precise measure of how frequently each customer makes a purchase.

4. **Validate and Save:**
   - Click the `Validate` button to check the syntax of your formula. If everything is correct, click `OK` to save your calculated field.

5. **Use the Frequency Column:**
   - Drag your newly created "Frequency" calculated field onto your desired shelf (Rows, Columns, or Marks Card) to incorporate it into your analysis.

By following these steps, you create a calculated column named "Frequency" that accurately represents the number of unique purchasing dates for each customer, effectively measuring the purchase frequency. This method leverages the power of the FIXED function to perform the calculation at the customer level, ensuring that the analysis remains accurate and relevant, regardless of other dimensions in your Tableau view[3][2].

Citations:
[1] https://www.youtube.com/watch?v=JuEGM34FSbI
[2] https://www.rigordatasolutions.com/post/how-to-use-count-and-count-distinct-in-tableau
[3] https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_lod_fixed.htm
[4] https://community.tableau.com/s/question/0D54T00000C6UlnSAF/create-a-frequency-table-with-measure-names-and-measure-values
[5] https://community.tableau.com/s/question/0D54T00000C6iApSAJ/calculated-field-to-show-distinct-count-with-conditions
[6] https://hevodata.com/learn/tableau-fixed/
[7] https://community.tableau.com/s/question/0D54T000018bFlRSAU/how-to-create-a-frequency-distribution-chart
[8] https://community.tableau.com/s/question/0D54T00000dYpuySAC/help-creation-a-calculated-field-that-count-distinct-values-based-on-a-condition-and-by-group
[9] https://www.youtube.com/watch?v=4u644h6ltS0
[10] https://community.tableau.com/s/question/0D54T00000C5d0KSAR/how-do-i-create-a-2d-frequency-table-with-more-than-one-column-to-store-a-number-of-calculated-statistics
[11] https://community.tableau.com/s/question/0D54T00001IjL9WSAV/how-to-get-a-distinct-count-as-a-calculated-field
[12] https://www.thedataschool.com.au/pris-lam/how-to-use-level-of-detail-in-tableau-fixed-function/
[13] https://www.youtube.com/watch?v=WvU6Biuecss
[14] https://kb.tableau.com/articles/howto/getting-distinct-count-when-countd-is-not-available
[15] https://community.tableau.com/s/question/0D54T00000C64wLSAR/how-to-make-a-stacked-count-frequency-of-a-column
[16] https://www.youtube.com/watch?v=rmkAf8Escro
[17] https://www.youtube.com/watch?v=6QX_rF2pIrQ
[18] https://stackoverflow.com/questions/41686621/how-can-i-calculate-a-distinct-count-of-a-dimension-in-tableau
[19] https://community.tableau.com/s/question/0D54T00000F33meSAB/is-there-a-way-to-create-dynamic-frequency-tables
[20] https://community.tableau.com/s/question/0D54T00000K606iSAB/help-create-count-distinct-based-off-calculated-field

To enhance the instruction for calculating the total spending (Monetary value) for each "Customer ID" in Tableau, we will clarify the use of the SUM function instead of COUNTD, as we are interested in the total sum of "Amount" rather than a distinct count. Here's the improved instruction:

### Improved Instruction:

In this example, our goal is to calculate the total monetary value of purchases for each customer. This is a crucial step in understanding customer behavior by measuring their total spending. We will use the SUM function in Tableau to aggregate the "Amount" spent by each "Customer ID".

Here's how to create the Monetary Column to calculate the total sum of "Amount" for each "Customer ID":

1. **Open the Calculated Field Editor:**
   - Right-click in the Data pane and select `Create Calculated Field` to open the editor.

2. **Enter the Calculated Field Name:**
   - Name your calculated field something descriptive, such as "Monetary".

3. **Construct the Calculation:**
   - In the formula area, enter the following expression:
     ```
     SUM([Amount])
     ```
   - This formula tells Tableau to sum up all the values in the "Amount" field for each "Customer ID". Unlike COUNTD, which counts distinct occurrences, SUM adds up all the numerical values, giving us the total spending per customer.

4. **Validate and Save:**
   - Click the `Validate` button to ensure the formula is correct. If there are no errors, click `OK` to save your calculated field.

5. **Use the Monetary Column:**
   - Drag your newly created "Monetary" calculated field onto your desired shelf (Rows, Columns, or Marks Card) to visualize the total spending by each customer in your analysis.

By following these steps, you create a calculated column named "Monetary" that represents the total amount of money spent by each customer. This calculation is essential for analyzing customer value and segmenting customers based on their spending behavior.

To enhance the instruction for calculating the "Recency" column, which measures the day difference between a specific reference date and each customer's most recent purchase date, here's a refined version of the instruction. This version aims to provide clarity and facilitate understanding for undergraduate students:

### Improved Instruction:

In this example, we aim to calculate the "Recency" of each customer's purchases. "Recency" refers to the number of days that have elapsed since a customer's last purchase, up to a specific reference date. For our purposes, we will use "6/9/2023" as the reference date, which represents the latest date in the entire "Sale Date" column.

Here's how to create the "Recency" column to calculate the day difference between "6/9/2023" and each customer's most recent purchase date:

1. **Open the Calculated Field Editor:**
   - Right-click in the Data pane and select `Create Calculated Field` to open the editor.

2. **Enter the Calculated Field Name:**
   - Name your calculated field "Recency".

3. **Construct the Calculation:**
   - In the formula area, enter the following expression:
     ```
     DATEDIFF("day", {FIXED [Customer ID]: MAX([Sale Date])}, DATE("6/9/2023"))
     ```
   - This formula uses the `DATEDIFF` function to calculate the number of days between two dates. The `FIXED` Level of Detail (LOD) expression calculates the maximum (or most recent) "Sale Date" for each "Customer ID". The `DATEDIFF` function then computes the difference in days between this most recent purchase date and the reference date "6/9/2023".

4. **Validate and Save:**
   - Click the `Validate` button to check the syntax of your formula. If there are no errors, click `OK` to save your calculated field.

5. **Use the Recency Column:**
   - Drag your newly created "Recency" calculated field onto your desired shelf (Rows, Columns, or Marks Card) to analyze the recency of purchases by each customer in your analysis.

By following these steps, you create a calculated column named "Recency" that accurately reflects the number of days since each customer's last purchase, relative to the reference date "6/9/2023". This calculation is crucial for analyzing customer engagement and identifying customers who have recently interacted with your business[1][2][3].

Citations:
[1] https://www.rigordatasolutions.com/post/datediff-function-in-tableau
[2] http://www.learntableau.technology/p/tableau-datediff-function.html?m=1
[3] https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_lod_fixed.htm
[4] https://help.tableau.com/current/pro/desktop/en-us/functions_functions_date.htm
[5] https://community.tableau.com/s/question/0D54T00000C6JvYSAV/datediff-to-calculate-number-of-days
[6] https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_lod_overview.htm
[7] https://community.tableau.com/s/question/0D58b00009sk3hOCAQ/how-to-use-today-in-datediff-function
[8] https://community.tableau.com/s/question/0D54T00000C67iFSAR/minmax-values-using-lod-expressions
[9] https://community.tableau.com/s/question/0D54T00000C6gP1SAJ/i-need-to-calculate-days-in-between-two-dates
[10] https://community.tableau.com/s/question/0D58b0000BGOgmBCQT/lod-expression-to-calculate-max-and-min-sales-on-3-different-levelsviews
[11] https://www.youtube.com/watch?v=BIDRFeiVlEQ
[12] https://help.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_lod.htm
[13] https://www.projectpro.io/recipes/does-datediff-function-work-tableau
[14] https://www.youtube.com/watch?v=5ntCaHCsqUc
[15] https://hevodata.com/learn/datediff-tableau/
[16] https://community.tableau.com/s/question/0D54T00000C6e9CSAR/fixed-min-max-calculation
[17] https://www.youtube.com/watch?v=agr3PIXUIdE
[18] https://www.rigordatasolutions.com/post/how-to-use-fixed-level-of-detail-lod-expression-in-tableau

To enhance the instruction for adding clusters in Tableau, which involves utilizing the "Analytics" tab and the "Clusters" feature, here's a refined version of the instruction aimed at providing clarity and facilitating understanding for users:

### Enhanced Instruction for Creating Clusters in Tableau

In this guide, we focus on leveraging Tableau's clustering feature to identify natural groupings within your data. Clustering is a powerful analytical technique that partitions your data into clusters based on similarity. For this task, we will use the "Clusters" option available under the "Analytics" tab in Tableau.

#### Steps to Add Clusters to Your View:

1. **Navigate to the Analytics Pane:**
   - Locate the "Analytics" tab on the left side of your Tableau workspace. This pane is situated above the "Data" pane and can be accessed by clicking on the "Analytics" tab.

2. **Initiate the Clustering Process:**
   - Within the "Analytics" pane, you will find various analytical tools. Look for the "Clusters" option.
   - You can add clusters to your view by either dragging the "Clusters" option directly into your view or by double-clicking on "Clusters". This action instructs Tableau to automatically identify and create clusters based on the data present in your view[1].

3. **Tableau Creates and Colors Clusters:**
   - Upon adding "Clusters" to your view, Tableau generates a Clusters group and applies color coding to visually distinguish the different clusters. If there was a field already assigned to the "Color" mark, Tableau would move that field to "Detail" and replace it with the clustering results[1].

4. **Customize Your Clusters:**
   - After the initial clustering, a "Clusters" dialog box appears, allowing you to customize the cluster results. Here, you can:
     - Add or remove variables by dragging fields from the Data pane into or out of the "Variables" area within the dialog box. This step adjusts which data dimensions or measures Tableau considers when forming clusters.
     - Specify the desired number of clusters, ranging from 2 to 50. If you do not specify a number, Tableau will automatically create up to 25 clusters based on the data[1].

5. **Finalize and Apply Clusters:**
   - Once you have customized your clusters to your satisfaction, close the "Clusters" dialog box by clicking the "X" in the upper-right corner. Your view will now reflect the clustering analysis, with data points colored according to their assigned cluster.

6. **Further Analysis and Customization:**
   - You can further analyze and customize your clusters by right-clicking on the Clusters group on the "Color" shelf. This action allows you to edit the clusters, rename them, or even save them as a group for future use[1].

By following these steps, you can effectively use Tableau's clustering feature to uncover patterns and groupings within your data, providing valuable insights for your analysis.

Citations:
[1] https://help.tableau.com/current/pro/desktop/en-us/clustering.htm
[2] https://help.tableau.com/current/pro/desktop/en-us/environ_workspace_analytics_pane.htm
[3] https://towardsdatascience.com/cluster-analysis-in-tableau-1f19acd0c647
[4] https://www.datacamp.com/tutorial/cluster-analysis-in-tableau
[5] https://www.youtube.com/watch?v=d5O48p2oMGs
[6] https://community.tableau.com/s/question/0D54T00000C63fASAR/dynamic-clusters-in-dashboard
[7] https://www.youtube.com/watch?v=EFvLpjh2NcU
[8] https://playfairdata.com/definitive-guide-to-the-analytics-pane-in-tableau/