【问题标题】:Tableau case when statement - invalid syntax (missing identifier)Tableau case when 语句 - 语法无效(缺少标识符)
【发布时间】:2019-04-30 07:21:53
【问题描述】:

我写过:

case when [count_total_cre] <= 75 then (sum([count_total_cre])*15) else 0 end 

这适用于 SQL。

当我尝试添加 Tableau 计算字段时出现以下错误:

语法错误(可能您缺少标识符)

我错过了什么?谢谢!

【问题讨论】:

    标签: syntax-error case tableau-api


    【解决方案1】:

    Tableau 的计算语言不允许在 case 语句中使用范围比较运算符。您需要在此处使用 if 语句。

    if sum([count_total_cre]) <= 75 then (sum([count_total_cre])*15) else 0 end 
    

    请注意,您必须在两边都使用单个值或聚合表达式。以下也是有效的:

    if [count_total_cre] <= 75 then [count_total_cre]*15 else 0 end 
    

    你使用哪一个取决于你的最终目标。

    如果您好奇,Tableau 中的案例格式如下:

    case [Sales]
    when 75 then [Sales]*15
    when xx then yy
    else zz
    end
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-12
    • 2020-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-17
    • 1970-01-01
    相关资源
    最近更新 更多