我有桌子
当我选择过滤器窗格 2 年 2018 年和 2016 年 ((60000+18000)/(30000+20000))^(1/(2018-2016))-1 时,我想计算 qliksense 中 Total_amt 的 CAGR,当我仅选择 1 年并将较低年份设置为 2016 年,例如:我在筛选器窗格中选择 2019 年,然后计算 2016 年到 2019 年的复合年增长率。
我也希望能够通过 flag_new 进行过滤
有人知道在qliksense中做这个表达吗
在数据加载编辑器中加载数据:
Data:
Load *
Inline [
Years, flag_new, total_amt, count_cust
2016, new, 20000, 1500
2016, exs, 30000, 1600
2017, new, 18000, 1400
2017, exs, 60000, 3100
2018, new, 21000, 2000
2018, exs, 90000, 4500
2019, new, 20500, 1500
];
并在图表中使用这个公式,例如KPI图表,..
If(GetSelectedCount(Years) = 1,
Pow(Sum({<Years={"$(=Max(Years))"}>} total_amt)/Sum({<Years={"$(=Min(All Years))"}>} total_amt), 1/(Max(Years) - Min({<Years>} Years) + 1) - 1),
Pow(Sum({<Years={"$(=Max(Years))"}>} total_amt)/Sum({<Years={"$(=Min(Years))"}>} total_amt), 1/(Max(Years) - Min(Years) + 1) - 1))
应该适合你。
这有点笨拙,因为有两种不同的情况:当只选择一年时,总是将 2016 年作为最小值(年);当选择超过一年时,在选择范围内取最大值和最小值。