【问题标题】:How can Max() work within sumif in an expression on Qliksense?Max() 如何在 Qliksense 上的表达式中的 sumif 中工作?
【发布时间】:2017-01-11 01:08:05
【问题描述】:

我写了一个表达式来计算 [Benefit] 排名前 10 位的 [Spend by Vendor] 的总和。

Sum(if([H4 Benefit by Vendor] > Max([H4 Benefit by Vendor],11), [Spend by     Vendor],0))/sum([Spend by Vendor])

但是,这个表达式不起作用。

我试图将表达式分成两个并进行测试。 (将 Max() 部分替换为 0)

  1. Sum(if([H4 Benefit by Vendor] >0, [Spend by Vendor],0))/sum([Spend by Vendor])
  2. Max([H4 Benefit by Vendor],11)

他们独立工作得很好。但是组合在一起就不行了。

请问有什么方法可以将这两者结合起来吗?

【问题讨论】:

    标签: max sumifs qliksense


    【解决方案1】:

    问题是将聚合值与行值进行比较 - 您不能直接执行此操作,但根据 thread 有一些选项。

    我这样做的方法是在加载脚本上设置一个变量

    Temp:
    load
        max([H4 Benefit by Vendor]) as maxB
    resident TABLENAME;
    
    LET vBenefitMax = peek('maxB');
    
    drop table Temp;
    

    然后在您的 If 声明中引用它。

        Sum(if([H4 Benefit by Vendor] > vBenefitMax, [Spend by Vendor],0))
    / sum([Spend by Vendor])
    

    【讨论】:

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