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



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

可以使用 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

最新更新