如何在Tableau中创建当年和上一年销售总额的计算字段?

时间:2018-05-23 10:00:41

标签: tableau

如何在画面中为当年和上一年的销售总额创建计算字段?

1 个答案:

答案 0 :(得分:1)

您可以使用if语句在计算中有效嵌入过滤条件,默认情况下,对不满足条件的数据行求值为null。像Sum()这样的聚合函数默默地忽略空值。

<强> current_year_sales

If Year([Sale Date]) = Year(Today()) then [Sale Amount] end

<强> prior_year_sales

If Year([Sale Date]) = Year(DateAdd(‘year’, -1, [Sale Date])) then [Sale Amount] end
相关问题