我正在处理一个Tableau项目,该项目的长格式表格数据显示开始月份,结束月份和每月成本。我试图显示日期(每月)费用的(动态)范围,然后覆盖多月行总费用的参考线。我怀疑答案在于使用细节层次(LOD)表达式,但似乎无法弄清楚。
csv示例:
start,end,month length,x,a,b,c,d,total
1/1/2019,1/1/2019,1,1.2,0.08,0.01,0.1,0.299,0.489
2/1/2019,2/1/2019,1,1.1,0.08,0.01,0.1,0.295,0.485
3/1/2019,3/1/2019,1,0.9,0.08,0.01,0.12,0.285,0.495
1/1/2019,2/1/2019,2,2.3,0.08,0.01,0.1,0.297086956521739,0.487086956521739
2/1/2019,3/1/2019,2,2,0.08,0.01,0.109,0.2905,0.4895
1/1/2019,3/1/2019,3,3.2,0.08,0.01,0.105625,0.2936875,0.4893125
忽略x,a,b,c,d-它们是为了显示图表具有等于每月总计的多个度量。
对于相同的开始和结束月份,我们有一个month length: 1
。与这些行关联的值是每月值。为了绘制动态的月份范围,我可以通过过滤month length: 1
并添加用于将开始日期设置为结束日期范围[Start Date] >= [Selected Start Date] AND [Start Date] <= [Selected End Date]
鉴于此表,我如何显示针对所选的开始到结束范围(total
,start date: 1/1/2019
,end date: 3/1/2019
)的month length: 3
值的参考线,即使有month length: 1
的过滤器?最终结果将是一行0.4893125
答案 0 :(得分:0)
是的,是的,您需要使用LoD。
如果您需要绕过过滤器,则使用LoD Fixed
,尽管过滤器为month = 3
,下面的代码段将为您提供month=1
的数据。根据您的要求更改代码:
{ FIXED : Max(IF [Month Length] = 3 THEN [A] END)}
编辑------------------------------------------------ ------------------------
{ FIXED :
Max(
IF ([Start Date] >= [Selected Start Date] AND
[Start Date] <= [Selected End Date]) AND
[Month Length] = 3 THEN [A] END)}