解决Tableau中IF结果的汇总和非汇总混合错误

什里娅·巴塔查里亚(Shreya Bhattacharya)

我正在尝试在Tableau中执行以下操作。

如果选择的关键指标是销售额或销量(非汇总字段),则调用calculation1否则计算2。

IF ATTR([Choose Key Figure])= "Sales"
THEN [Periodic Calculation]
ELSEIF ATTR([Choose Key Figure])= "Volume"
THEN [Periodic Calculation]
ELSEIF ATTR([Choose Key Figure])="profit"
THEN [Periodic Calculation 2]
ELSEIF ATTR([Choose Key Figure])="price per unit"
THEN [Periodic Calculation 2]
END 

但是我收到以下错误:“无法混合汇总和非汇总比较,或者无法生成'IF'表达式。”

定期计算

IF [Choose Vol/NNS]="NNS"
AND [Choose Period]=-1
AND DATEDIFF("month",[Dates], [Choose Current Month])<2
AND
DATEDIFF("month",[Dates],[Choose Current Month] )>0
then [(Actuals+Planned) NNS]
ELSEIF [Choose Vol/NNS]="Volume"
AND    [Choose Period]=-1
AND DATEDIFF("month",[Dates], [Choose Current Month])<2
AND
DATEDIFF("month",[Dates],[Choose Current Month] )>0
THEN [(Actuals + Planned) Volume]
ELSEIF [Choose Vol/NNS]="NNS"
AND [Choose Period]=-3
AND DATEDIFF("month",[Dates], [Choose Current Month])<4
AND
DATEDIFF("month",[Dates],[Choose Current Month] )>0
then [(Actuals+Planned) NNS]
ELSEIF [Choose Vol/NNS]="Volume"
AND [Choose Period]=-3
AND DATEDIFF("month",[Dates], [Choose Current Month])<4
AND
DATEDIFF("month",[Dates],[Choose Current Month] )>0
THEN [(Actuals + Planned) Volume]
ELSEIF [Choose Vol/NNS]="NNS"
AND [Choose Period]=-6
AND DATEDIFF("month",[Dates], [Choose Current Month])<7
AND
DATEDIFF("month",[Dates],[Choose Current Month] )>0
then [(Actuals+Planned) NNS]
ELSEIF [Choose Vol/NNS]="Volume"
AND     [Choose Period]=-6
AND DATEDIFF("month",[Dates], [Choose Current Month])<7
AND
DATEDIFF("month",[Dates],[Choose Current Month] )>0
THEN [(Actuals + Planned) Volume]
ELSEIF [Choose Vol/NNS]="NNS"
AND     [Choose Period]=1
AND DATEDIFF("month",[Dates], [Choose Current Month])<0
AND
DATEDIFF("month",[Dates],[Choose Current Month] )>-2
THEN [(Actuals+Planned) NNS]
ELSEIF [Choose Vol/NNS]="Volume"
AND     [Choose Period]=1
AND DATEDIFF("month",[Dates], [Choose Current Month])<0
AND
DATEDIFF("month",[Dates],[Choose Current Month] )>-2
THEN [(Actuals + Planned) Volume]
ELSEIF [Choose Vol/NNS]="NNS"
AND     [Choose Period]=3
AND DATEDIFF("month",[Dates], [Choose Current Month])<0
AND
DATEDIFF("month",[Dates],[Choose Current Month] )>-4
THEN [(Actuals+Planned) NNS]
ELSEIF [Choose Vol/NNS]="Volume"
AND     [Choose Period]=3
AND DATEDIFF("month",[Dates], [Choose Current Month])<0
AND
DATEDIFF("month",[Dates],[Choose Current Month] )>-4
THEN [(Actuals + Planned) Volume]
ELSEIF [Choose Vol/NNS]="NNS"
AND     [Choose Period]=6
AND DATEDIFF("month",[Dates], [Choose Current Month])<0
AND
DATEDIFF("month",[Dates],[Choose Current Month] )>-7
THEN [(Actuals+Planned) NNS]
ELSEIF [Choose Vol/NNS]="Volume"
AND     [Choose Period]=6
AND DATEDIFF("month",[Dates], [Choose Current Month])<0
AND
DATEDIFF("month",[Dates],[Choose Current Month] )>-7
THEN [(Actuals + Planned) Volume]

结尾

定期计算2

IF [Choose IGM$/NNSP]="NNSP"
AND [Choose Period]=-1
AND ATTR(DATEDIFF("month",[Dates], [Choose Current Month]))<2
and ATTR(DATEDIFF("month",[Dates],[Choose Current Month] ))>0
THEN [(Actuals + Planned) NNSP]
ELSEIF [Choose IGM$/NNSP]="IGM$"
AND [Choose Period]=-1
AND ATTR(DATEDIFF("month",[Dates], [Choose Current Month]))<2
and ATTR(DATEDIFF("month",[Dates],[Choose Current Month] ))>0
THEN [(Actuals + Planned) IGM$]
ELSEIF [Choose IGM$/NNSP]="NNSP"
AND [Choose Period]=-3
AND ATTR(DATEDIFF("month",[Dates], [Choose Current Month]))<4
and ATTR(DATEDIFF("month",[Dates],[Choose Current Month] ))>0
THEN [(Actuals + Planned) NNSP]
ELSEIF [Choose IGM$/NNSP]="IGM$"
AND [Choose Period]=-3
AND ATTR(DATEDIFF("month",[Dates], [Choose Current Month]))<4
and ATTR(DATEDIFF("month",[Dates],[Choose Current Month] ))>0
THEN [(Actuals + Planned) IGM$]
ELSEIF [Choose IGM$/NNSP]="NNSP"
AND [Choose Period]=-6
AND ATTR(DATEDIFF("month",[Dates], [Choose Current Month]))<7
and ATTR(DATEDIFF("month",[Dates],[Choose Current Month] ))>0
THEN [(Actuals + Planned) NNSP]
ELSEIF [Choose IGM$/NNSP]="IGM$"
AND [Choose Period]=-6
AND ATTR(DATEDIFF("month",[Dates], [Choose Current Month]))<7
and ATTR(DATEDIFF("month",[Dates],[Choose Current Month] ))>0
THEN [(Actuals + Planned) IGM$]
ELSEIF [Choose IGM$/NNSP]="NNSP"
AND [Choose Period]=1
AND ATTR(DATEDIFF("month",[Dates], [Choose Current Month]))<0
and ATTR(DATEDIFF("month",[Dates],[Choose Current Month] ))>-2
THEN [(Actuals + Planned) NNSP]
ELSEIF [Choose IGM$/NNSP]="IGM$"
AND [Choose Period]=1
AND ATTR(DATEDIFF("month",[Dates], [Choose Current Month]))<0
and ATTR(DATEDIFF("month",[Dates],[Choose Current Month] ))>-2
THEN [(Actuals + Planned) IGM$]
ELSEIF [Choose IGM$/NNSP]="NNSP"
AND [Choose Period]=3
AND ATTR(DATEDIFF("month",[Dates], [Choose Current Month]))<0
and ATTR(DATEDIFF("month",[Dates],[Choose Current Month] ))>-4
THEN [(Actuals + Planned) NNSP]
ELSEIF [Choose IGM$/NNSP]="IGM$"
AND [Choose Period]=3
AND ATTR(DATEDIFF("month",[Dates], [Choose Current Month]))<0
and ATTR(DATEDIFF("month",[Dates],[Choose Current Month] ))>-4
THEN [(Actuals + Planned) IGM$]
ELSEIF [Choose IGM$/NNSP]="NNSP"
AND [Choose Period]=6
AND ATTR(DATEDIFF("month",[Dates], [Choose Current Month]))<0
and ATTR(DATEDIFF("month",[Dates],[Choose Current Month] ))>-7
THEN [(Actuals + Planned) NNSP]
ELSEIF [Choose IGM$/NNSP]="IGM$"
AND [Choose Period]=6
AND ATTR(DATEDIFF("month",[Dates], [Choose Current Month]))<0
and ATTR(DATEDIFF("month",[Dates],[Choose Current Month] ))>-7
THEN [(Actuals + Planned) IGM$]
END

谁能帮助您解决此错误?

谢谢。

亚历克斯·布莱克摩尔

如果[Choose Key Figure]是参数,并且[Periodic Calculation]和[Periodic Calculation 2]是行级(非聚合)计算,则可以:

  1. 在您计算的字段中删除所有对ATTR()的调用,或者
  2. 删除对ATTR()的所有调用,并在对[Periodic Calculation]或[Periodic Calculation 2]的每个引用上调用诸如SUM()之类的聚合函数,或者
  3. 保留对ATTR()的调用,并在对[Periodic Calculation]或[Periodic Calculation 2]的每个引用上调用诸如SUM()之类的聚合函数

1和2之间的区别是是在计算中还是在使用该表的Tableau工作簿书架中为计算字段指定聚合函数。

在这种情况下,没有真正的理由选择第三种方法,因为一次只能有一个参数,因此ATTR()调用没有用。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

无法将汇总和非汇总比较与COUNT混合使用

来自分类Dev

建立汇总结果的总和

来自分类Dev

汇总和绘制公开调查表中的观察结果

来自分类Dev

Tableau中的汇总箱

来自分类Dev

R中的汇总和总计

来自分类Dev

mongo按月汇总和返回结果

来自分类Dev

dax 汇总和标量错误的问题

来自分类Dev

汇总和汇总每日数据到python中的月份

来自分类Dev

SQL 2汇总给出错误的结果

来自分类Dev

如何在R中的组内汇总和计算非缺失,非零和非唯一值?

来自分类Dev

建立已汇总和分组数据结果的对象树

来自分类Dev

汇总/按总和分组

来自分类Dev

Django汇总,计数总和

来自分类Dev

汇总和分组值

来自分类Dev

分组汇总和

来自分类Dev

逐步构建(汇总)总和

来自分类Dev

汇总和更新MongoDB

来自分类Dev

Mongo汇总与总和

来自分类Dev

Django汇总,计数总和

来自分类Dev

MongoDB汇总和计数

来自分类Dev

Postgresql汇总和非汇总列的使用情况,按分组

来自分类Dev

汇总结果在猫鼬中

来自分类Dev

在JPARepository中获取汇总的查询结果

来自分类Dev

汇总熊猫表中的循环结果

来自分类Dev

Tableau汇总到值范围的箱中

来自分类Dev

MSCRM 2011汇总和语言包错误

来自分类Dev

通过加入多个表汇总汇总和汇总

来自分类Dev

汇总返回多个值的函数的非嵌套结果

来自分类Dev

枢转具有汇总功能的列,并计算最后一列中的汇总值的总和