Tableau – Numeric Calculations

Numeric calculations in Tableau perform mathematical operations on numeric fields to create new calculations, metrics, or insights. Let’s look at some examples to understand the concept.

Types of Numeric Calculations

The following are some common types of numeric calculations. Consider fields as Field A, Field B, etc.

Arithmetic Calculations

  1. Addition: Field A + Field B
  2. Subtraction: Field A – Field B
  3. Multiplication: Field A * Field B
  4. Division: Field A / Field B
  5. Modulus: Field A % Field B (remainder of division)
  6. Exponentiation: Field A ^ Field B (raise to power)

Comparison Calculations

  1. Equal: Field A = Field B
  2. Not Equal: Field A ≠ Field B
  3. Greater Than: Field A > Field B
  4. Less Than: Field A < Field B
  5. Greater Than or Equal: Field A ≥ Field B
  6. Less Than or Equal: Field A ≤ Field B

Logical Calculations

  1. AND: Field A AND Field B (both conditions true)
  2. OR: Field A OR Field B (either condition true)
  3. NOT: NOT Field A (reverse condition)

Aggregate Calculations

  1. SUM: SUM(Field A)
  2. AVERAGE: AVG(Field A)
  3. MAX: MAX(Field A)
  4. MIN: MIN(Field A)
  5. MEDIAN: MEDIAN(Field A)
  6. COUNT: COUNT(Field A)

Advanced Calculations

  1. RANK: RANK(Field A)
  2. PERCENTILE: PERCENTILE(Field A, 0.5) (50th percentile)
  3. STDEV: STDEV(Field A) (standard deviation)
  4. VARIANCE: VARIANCE(Field A)
  5. CORREL: CORREL(Field A, Field B) (correlation coefficient)

Example

Let us see an example of numerical calculations.

Open Tableau and let us create a new Tableau workbook. Go to File and click New:

1. Create a new workbook in Tableau

After opening a new file, go to File and click Save As:

2. Save a new workbook in Tableau

Save the file as Amit_Tableau_Calculations.twb:

3. Save the Tableau Workbook in the Workbooks folder

We saved our new workbook successfully above. Now, click Connect to Data to upload the data source:

4. Connect to Data in Tableau

Click Microsoft Excel and select the sample xls file we selected in the previous lessons, i.e., Sample – Superstore.xls. Select the .xls file and click Open:

5. Connect to sample superstore in Tableau

All the tables (excel workbook sheets) are now visible on the left. Drag the Orders sheet to the canvas:

6. The workbooks of the sample superstore visible in Tableau

The Orders table (sheet) is now visible with the rows and columns.

Click the Sheet 1 below to reach the Worksheet so that we can begin with the calculations:

7. Orders table dragged to the canvas in Tableau

We have renamed the Sheet 1 to Numeric Calculations. Also, the fields of the Orders table are visible on the left:

8. Fields of the Orders Table in Tableau

Create Aggregate Calculations

Let us create a calculated field using the aggregate function. We will create minimum sales values for different ship modes.

Go to the Analysis menu and click on it. After that, click Create Calculated Field:

9. Create a Calculated Field a Tableau

Click on the arrow to display all the built-in functions. From the dropdown, click Number to display only the numerical functions:

10. Name the Calculated field in Tableau

Set the name of the calculation. We will set it to Minimum_Sales_ShipMode to create minimum sales values for different ship modes.

From the right, select the MIN() function. After selecting, on the left, set the formulae for minimum sales i.e.  MIN([Sales]) :

11. MIN() number function in Teableu

Now, the formulae can be seen and there are no error messages. Click OK:

12. Calculation formulae in Tableau for a field

On the left, the new calculation field is visible i.e.,  Minimum_Sales_ShipMode:

13. The new calculated field created in Tableau

Drag the Ship Mode to the Columns shelf, and the new Minimum_Sales_ShipMode to the Columns shelf.

On the Rows shelf, the AGG is visible. Here, AGG means Aggregate.

After dragging, the bar chart will be visible as shown below:

14. Fields dragged to the rows and columns shelf in Tableau

Keep the mouse cursor to display the ship mode and minimum sales for a specific mode:

15. Numeric calculations in Tableau


If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.


For Videos, Join Our YouTube Channel: Join Now


Read More:

Joins in Tableau
Tableau - String Calculations
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading