1
我正在嘗試在Tableau中執行以下操作。解決Tableau中IF結果的聚合和非聚合混合錯誤
如果選擇的關鍵人物是銷售或體積(非集合字段),然後調用計算1其他計算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]
END
定期計算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
任何人都可以如何解決這個錯誤幫助嗎?
謝謝。
謝謝亞歷克斯。解決方案完美無缺。 –