首页 > 解决方案 > 为 tableau 中的多个 if 语句获取正确的计算

问题描述

我正在尝试在画面上写一个 if then 语句,但我可能会遗漏一些东西,这是一个多重比较我现在拥有的东西 If {Receive Campus match } = false then '0' Else If { matches lag} = true then true else false否则,如果 { 计划货物与发货之间的天数差异} < = 0 那么 { 固定.......} 有一个 LOD ELSE '0' End End End 但它不正确!将需要帮助

标签: tableau-apivisualizationbusiness-intelligence

解决方案


由于您尚未上传任何数据/屏幕截图,因此很难理解您的问题,但我可以在您提出的计算中看到一些错误。

你提出的计算,如果分成短语,就会变成这样——

line-1  If {Receive campus match } = false 
line-2  then ‘0’ 
line-3  Else If { matches lag} = true 
line-4  then true 
line-5  else false 
line-6  Else If { days difference between goods planned vs shipped} < = 0 
line-7  Then { fixed .......} there’s an LOD 
line-8  ELSE ‘0’ 
line-9  End End End

问题 1:在画面中有ELSEIF和没有ELSE IF

问题 2:一旦提供了(第 5 行),您就不能开始新的else if(原文如此!)(第 6行)else

问题 3:为什么END在第 9 行有 3 个?

基本上 IF THEN ELSE IF ELSE END 的语法是这样的......

IF    <Condition>
Then <Result 1>
ELSEIF  <condition 2>
then <Result>
... Repeat ELSEIF and THEN here, if you have several conditions

ELSE <last result corresponding to last false condition>
END

推荐阅读