Tableau:如何计算同比保留率(当年值除以上一年值之和)
根据屏幕截图(如下),我想在 Tableau 中计算当前值(今年的“返回”总计)与上一年总计(上一年的“新”+“返回”总计)之和的百分比。
我的想法是我可以:
- 为每个 [Level] 添加 [DistinctPersons] 的“总计”(使用LOD,但这会返回“聚合的聚合”错误);然后...
- 对于[新的或返回]中的每个“返回”值,将当前年份的“返回”值除以上一年计算的“总计”值。
我知道这可能涉及 LOD 和窗口函数的某种组合,但是,由于该度量已经是聚合结果,因此比我想象的要棘手一些。
As per the screenshot (below), I would like to calculate in Tableau the percentage of a current value (this year's "RETURNING" total) versus the sum of a previous year's totals (previous year's "NEW" + "RETURNING" total).
My thinking is that I could:
- Add the "Total" of [DistinctPersons] for each [Level] (using a LOD, but this returns an "aggregate of aggregates" error); then …
- For each "RETURNING" value in [New or Returning], divide the current year's "RETURNING" value by the previous year's calculated "Total" values.
I know this probably would involve some combination of LODs and window functions but, because the measure is already an aggregate result, it's a bit trickier than I thought.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您从列架中删除 Year,并从行架中删除 New 或 Returning,则执行以下操作:
由于 [DistinctPersons] 已聚合,因此其他字段周围需要 ATTR()。
If you remove Year from the columns shelf and New or Returning from the row shelf, you do the following:
Since [DistinctPersons] is already aggregated, the ATTR() is required around the other fields.