2 MINUTE READ | September 27, 2016
Average Calculation in Tableau
Last updated: November 2021
There’s a bit of a misconception about how Tableau calculates average numbers. I’ve seen analysts struggle with this seemingly easy calculation.
Let’s use Tableau Superstore data and calculate Average Sales by Weekday. The common way would be to drop the date into rows field and then use AVG Sales calculation, like below.
The problem is that Tableau calculates average sales numbers based on each occurrence of the sale. Looking deeper we can see that we had multiple Order IDs and then multiple products within those order IDs as shown in one day sample below.
Tableau takes all sales occurrences and creates an average for all of them. So automatic AVG aggregation in Tableau will do SUM (Sales) / COUNT (Sales). If we wish to calculate an average per day (or weekday) we do need to make an extra calculated field since we want to have AVG aggregation as SUM (Sales) / COUNT (Days). How do we do this?
First, create a calculated field below, this will get us to a total daily sales. This calculation uses Level of Detail expressions which basically allow us to set the specific level of detail to run the aggregations, regardless of the filters or other levels of detail in the view.
Then we can use this total daily calculation to add to our visualization that has Weekday or Order Date in it and change the aggregation to an AVG to see the desired results. Below shows how results vary from Tableau’s default AVG Sales calculation and our new AVG Daily Sales. Tuesday, for example, had only one sales occurrence, so the numbers match up but as you can see other days produce totally different results due to multiple sales events.
Stay in touch
Subscribe to our newsletter
And now you know. Happy analysis.
AlliCampaigns & Client WorkData & TechnologyStrategyDigital MarketingCompany News
1 MINUTE READ | September 28, 2021
Consumer TrendsSocial MediaPlatforms & MediaDigital Marketing
4 MINUTES READ | August 30, 2021
2 MINUTES READ | February 4, 2020