使用 tableau 创建索引图表

Creating index chart with tableau

我正在尝试使用 Tableau 重新创建索引图表 (https://mbostock.github.io/protovis/ex/index-chart.html) for Makeover Monday 2021 W17 data set, and I cannot figure out what is the best approach to do this. I am using Tableau Public so I cannot attach the workbook as a document but you can find it here : https://public.tableau.com/views/RemakingMakeoverMondayW17IndexChart/Sheet14?:language=en-US&publish=yes&:display_count=n&:origin=viz_share_link

数据集包含美国的每个州以及该州 2008-2019 年间的价格指数。我想创建一个折线图,它将使用选定的年份作为比较条件,并显示每年与选定年份之间的差异。

我的方法如下:

  1. 我为日期“年参数”创建了一个参数。

  2. 我创建了一个计算字段“PARAMETER YEAR”来为我提供所选参数日期的价格指数:

IF [年份] = [年份参数] THEN [价格指数] END

  1. 我试图计算差异,这就是我卡住的地方:SUM([Price Index]) - SUM([PARAMETER YEAR])。此计算仅显示所选年份的 1 个州。

关于如何处理这个问题有什么想法吗?

试试这个作为你的参考指数:

{EXCLUDE [Year], [Regions], [Description]   : sum(
    IF DATEPART('year', [Year])= DATEPART('year', [Year Parameter]) THEN [Price Index]
         ELSE 0   
END)}