【问题标题】:Calculate the percent difference between two percentages at two dates in Tableau在 Tableau 中计算两个日期的两个百分比之间的百分比差异
【发布时间】:2019-04-18 06:12:08
【问题描述】:

我们的目标是创建一个列来显示百分比之间的百分比差异。

尝试在周围创建许多计算字段

-first() - last() -- 这只是计算周数差异

-if date = #2019-02-03# then sum number of records else null end -- invalid

-如果 date = #2019-02-03# then sum of records number else null end -- 无效

“过滤器 1”列是我希望显示此信息的位置。

预期结果: 过滤器 1 中的第 1 行应该 = 12%(-5 和 7 的绝对百分比变化)

非常感谢任何帮助!

【问题讨论】:

  • 开始日期和结束日期的标准是什么

标签: tableau-api


【解决方案1】:

我通过两种方式解决了这个问题: 一个创建了两个日期字段 - 一个用于一周,一个用于上周 :然后进行 diff % 测量并将这些用作列。

还有另一种方式,更粗糙:

if first() == 0 then
(
window_sum((if last() == 0 then sum(count_measure) end))
-(window_sum(if first()==0 then sum(count_measure) end))
)
/(window_sum(if first()==0 then sum(count_measure) end))
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-24
    • 1970-01-01
    • 2021-12-24
    相关资源
    最近更新 更多