Tableau Q:从重复行计算平均值

时间:2019-07-08 07:14:32

标签: sql-server database data-visualization tableau data-warehouse

我有这个具有表结构的数据仓库。我想使用Tableau创建可视化功能,以实现每年的平均客户点数。

CustomerID  ,Order      ,CustomerPoints ,OrderYear
A123        ,Table      ,450        ,2014
A123        ,Chair      ,450        ,2014
B236        ,Mouse      ,500        ,2014
B236        ,Keyboard   ,500        ,2014
B236        ,Monitor    ,500        ,2014
C135        ,Cabinet    ,600        ,2014
D246        ,Lamp       ,400        ,2014

如果我立即平均,它将计算7行,而不是4个不同的行。

这是应该如何计算的 CustomerID ,CustomerPoints ,OrderYear A123 ,450 ,2014 B236 ,500 ,2014 C135 ,600 ,2014 D246 ,400 ,2014 OrderYear, AverageCustomerPoints 2014, 487.5

CustomerPoints from each of customerID/count customerID (4 people)

我尝试使用{Fixed ([CustomerID]) : Average([CustomerPoints])}对每个客户ID进行计数,但是当我尝试使用其他表手动进行计算时,结果却有所不同。

有没有办法严格使用Tableau计算/功能来做到这一点?

2 个答案:

答案 0 :(得分:0)

您可以这样编写视图查询:

Traceback (most recent call last):
  File "/usr/local/sbin/button.py", line 25, in my_callback1
    asyncio.get_event_loop().run_until_complete(SendMessage(message))
  File "/usr/lib/python3.5/asyncio/events.py", line 671, in get_event_loop
    return get_event_loop_policy().get_event_loop()
  File "/usr/lib/python3.5/asyncio/events.py", line 583, in get_event_loop
    % threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'Dummy-1'.

答案 1 :(得分:0)

某人帮助 AVG({Fixed ([CustomerID]) : AVG([CustomerPoints])})