DVRP lp3
DVRP lp3
Objective:
To learn about Tableau calculations, including SUM, AVG, and aggregate features, and how to
create custom calculations and fields.
Materials:
● Tableau Software
● Example dataset (such as the Sample Superstore dataset)
Procedure:
SUM and AVG are two of the most common aggregate functions in Tableau. They are used to
calculate the total and average of a measure, respectively.
To calculate the sum of a measure, use the SUM() function. For example, to calculate the total
sales for each product category, you would use the following formula:
SUM([Sales])
To calculate the average of a measure, use the AVG() function. For example, to calculate the
average sales price for each product category, you would use the following formula:
AVG([Sales Price])
In addition to SUM and AVG, Tableau offers a variety of other aggregate functions, such as
MIN(), MAX(), MEDIAN(), and COUNT(). You can use these functions to calculate a variety of
different statistics about your data.
In addition to using the built-in aggregate functions, you can also create custom calculations and
fields in Tableau. This allows you to perform more complex calculations and to create new
measures and dimensions that are specific to your data.
To create a custom calculation, follow these steps:
1. Click the Add Field button and select Create Calculated Field.
2. In the Calculated Field Editor, enter a name for your calculation and write the formula for
your calculation.
3. Click the OK button to save your calculation.
For example, to create a calculation that calculates the profit margin for each product category,
you would use the following formula:
Once you have created a custom calculation, you can use it in your worksheets and
visualizations just like any other measure.
You can also create custom fields in Tableau. Custom fields are calculated fields that are based
on other fields in your data. For example, you could create a custom field that calculates the
year for each order date.
1. Click the Add Field button and select Create Custom Field.
2. In the Custom Field Editor, enter a name for your field and write the formula for your field.
3. Click the OK button to save your field.
Once you have created a custom field, you can use it in your worksheets and visualizations just
like any other field.
Example:
To create a line chart that shows the average sales by product category over time, you would
follow these steps:
1. Drag and drop the Order Date field to the Columns shelf.
2. Drag and drop the Product Category field to the Rows shelf.
3. Drag and drop the Sales field to the Marks shelf and select the Average mark type.
This will create a line chart that shows the average sales for each product category over time.
You can then customize the line chart to your liking, such as changing the colors, fonts, and
labels.
Conclusion:
By following this manual, you have learned about Tableau calculations, including SUM, AVG,
and aggregate features, and how to create custom calculations and fields. You can now use
these skills to perform complex calculations and to create new measures and dimensions that
are specific to your data.