Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tableau - weekly average from daily data

Tags:

tableau-api

Using Tableau 8.1.
Daily data like this:

Date     Sales
1-1-14     $5
1-2-14     $2
...
6-15-14    $15

Which can be aggregated to weeks of course

Week 1   $15
Week 2   $12
Week 3   $10
Week 4   $13

etc.

I would like to get the weekly average of each month
So like this:

          Weekly Average
Month 1     (weekly average of the weekly total sales)  ($15+$12+$10+13)/4 = 12.5
Month 2 
Month 3 

Does that make sense? If ou simply put "average" in the tableau table, it gives the average daily value PER WEEK (or month) < - I don't want that. I want the average of the weekly totals per month.

like image 599
Pat Stroh Avatar asked Mar 09 '15 20:03

Pat Stroh


People also ask

How do you calculate average weekly in Tableau?

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 I calculate weekly average from daily data in Excel?

(1) Click the Fruit column in the Column list, and click the Combine > Comma; (2) Click the Amount column, and click the Calculate > Average; (3) Click the Week column, and click the Primary Key; (4) Click the Ok button.

How do I work out my weekly average?

To calculate your average weekly working time you should add up the number of hours you worked in the reference period. Then divide that figure by the number of weeks in the reference period which is normally 17 weeks.


2 Answers

Quite simple, actually. Create these calculations

Unique Weeks = COUNTD(DATEPART('week',[Date]))
Weekly Average = sum([Sales])/[Unique Weeks]

Then simply report Weekly Average x Month (or Quarter or Year, etc.)
(Note: Some weeks have < 7 days).

like image 76
Pat Stroh Avatar answered Nov 08 '22 23:11

Pat Stroh


This can be done very simply with one calculated field.

WINDOW_AVG(SUM([Sales]))

Then drag your Date pill onto the rows shelf twice, one aggregated to day, the other to week. Make sure pills are set to discrete (blue) and drag your Sales measure onto the shelf, also as discrete.

like image 4
keberwein Avatar answered Nov 09 '22 01:11

keberwein