BUILDING ARITHMETIC CALCULATIONS
Arithmetic calculations are also called Number Functions
Number functions allow us to perform computations on the data values in the
fields.
Number functions can only be used with fields that contain numerical values.
For example, you might have a requirement to Rounds a number or a field to the
nearest integer of equal or lesser value.
For this we can use the FLOOR function
The calculation might look something like this:
FLOOR(SUM([Sales]))
There are many Aggregate functions available in Tableau, but we will be going
through only 2 functions
FLOOR
CEILING
BUILDING ARITHMETIC CALCULATIONS
Syntax for FLOOR function :
FLOOR(number)
Description of FLOOR function :
Rounds a number to the nearest integer of equal or lesser value.
Syntax for CEILING function:
CEILING(number)
Description of CEILING function :
Rounds a number to the nearest integer of equal or greater value.
STEPS TO FLOOR AND CEILING FUNCTION
Step 1: Select Analysis > Create Calculated Field
STEPS TO FLOOR AND CEILING FUNCTION
Step 2: Calculation Editor will open
STEPS TO FLOOR AND CEILING FUNCTION
Step 3: Name the calculated field, Floor Sales.
Enter the below mentioned formula
FLOOR(SUM([Sales]))
Confirm that a "The calculation is valid" message is seen
When finished, Click OK
STEPS TO FLOOR AND CEILING FUNCTION
Step 4: Name the calculated field, Ceiling Sales.
Enter the below mentioned formula
CEILING(SUM([Sales]))
Confirm that a "The calculation is valid" message is seen
When finished, Click OK
STEPS TO FLOOR AND CEILING FUNCTION
Step 5: The new calculated field appears under Measures in the Data pane.
Just like other fields, we can use it in one or more visualizations.
STEPS TO FLOOR AND CEILING FUNCTION
Step 6: Right-click Sales field, Default Properties > Number Format >
Number(Custom) > Decimal places ‘2’
STEPS TO FLOOR AND CEILING FUNCTION
Step 7: When Floor Sales and Ceiling Sales is placed on a shelf or card in
the worksheet, its name is changed to AGG( ),
which indicates that it is an aggregate calculation and cannot be aggregated
any further.
STEPS TO FLOOR AND CEILING FUNCTION
Step 8: Check the FLOOR and CEILING calculations in the below Viz
STEPS TO FLOOR AND CEILING FUNCTION
Step 9: Ceiling provides the nearest integer of equal or greater value
Floor provides the integer of equal or lesser value
e.g.: Ceiling Sales for Copiers is 149,529
Floor Sales for Copiers is 149,528