tableau-api - 如何在 Tableau 中为当年和上一年的销售额总和创建计算字段?
问题描述
如何在表格中为当年和上一年的销售额总和创建计算字段?
解决方案
您可以使用 if 语句将过滤条件有效地嵌入计算中,对于不满足您的条件的数据行,默认情况下评估为 null。Sum() 之类的聚合函数会默默地忽略空值。
current_year_sales
If Year([Sale Date]) = Year(Today()) then [Sale Amount] end
previous_year_sales
If Year([Sale Date]) = Year(DateAdd(‘year’, -1, [Sale Date])) then [Sale Amount] end
推荐阅读
- r - Rcpp 乘以从矩阵行中提取的向量以形成矩阵
- javascript - 可以在不使用 Google Maps API 的情况下进行车辆跟踪吗?
- msbuild - msbuild 警告 - MSB3246 & NETSDK1049
- discord - 如何让不和谐的机器人发送邀请?
- express - 我正在尝试通过 heroku 部署 MEAN 应用程序,但我陷入了困境
- javascript - 对话流返回一个空响应,尽管有数据
- kotlin - 错误:Kotlin 中的重载分辨率歧义
- angular - 角度文件上传不适用于 formData
- python-3.x - Selenium webdriver既不打开Chrome也不打开Firefox浏览器,我在pycharm中下载了chromedriver、geckodriver
- javascript - onClick 函数或模式的限制?