Tableau - weekly average from daily data

这一生的挚爱 提交于 2020-01-03 15:58:05

问题


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.


回答1:


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).




回答2:


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.



来源:https://stackoverflow.com/questions/28951442/tableau-weekly-average-from-daily-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!