If your data source doesn’t include the fields that you are looking, then you can create a Calculated Field. In this article, we will show you, How to create calculated Field in Tableau with an example.
For this Tableau Calculated Field demonstration, we are going to use the data source that we created in our previous article so, Please visit Data Labels in Tableau Reports article to understand the Data Source.
How to Create Calculated Field in Tableau
You can create a Tableau calculated filed in multiple ways, and the first approach is: Please navigate to Analysis Tab and select the Create Calculated Field… option as shown below.
Once you click on the Create Calculated Field… option, a new window will be opened to write the calculation.
Second Approach to Create Calculated Field in Tableau
Please click on the Down arrow beside the Sales Amount Measure (change as per your requirement), or right click on it will open the context menu. From the list of available options, please select the Create option and then select the Calculated Field… option as shown below.
Once you click on the Calculated Field… option, a new window will be opened to write the calculation.
If you know the formula then you can write it directly on that Measure, or any other Measure. Or, If you don’t know the syntax of the function then click on the side arrow. Once you click on that arrow, it will list out all the functions available in Tableau as we shown below.
If you know the function name then use the search box to search for the item. And, if you don’t know then click the down arrow and select the function type
In this example, we will calculate the Running Total so, we are using the RUNNING_SUM function. Here, you can see the example to understand the syntax of a function.
Double click on it will automatically add the function to the calculated region. From the below screenshot you can observe that we changed the Calculated filed name to Sales Running Sum
Now you can see our newly created calculated filed
We created one table report to show our newly created calculated filed result. As you can see the last column is displaying the Running Total.
Edit Calculated Field in Tableau
In order to change the existing table calculation, please click on the down arrow beside the table calculation and select the Edit.. option as shown below.
Once you on click the Edit.. option, a calculated window will be opened to edit the existing calculation or function
Let us change the function name from RUNNING_SUM to RUNNING_AVG or write down your custom function and click OK
Now you can see that the last column in our report is displaying the Running Average
Thank You for Visiting Our Blog