0

我正在尝试获得如下 SQL 代码所示的功能:

select ....... , A.authorizedAction
, '1 - Add' = Case when (Cast((authorizedAction / 1) As Int) % 2) = 1 then 'Y' end
, '2 - Update/Display' = case when (Cast((authorizedAction / 2) As Int) % 2) = 1 then 'Y' end
, '4 - Update/Display all' = case when (Cast((authorizedAction / 4) As Int) % 2) = 1 then 'Y' end 
, '8 - Correction' = case when (Cast((authorizedAction / 8) As Int) % 2) = 1 then 'Y' end 
, A.authorizationActionKey   .... from ....

我想将所有 4 种情况(添加、更新/显示、更新/显示全部和更正)表示为表格中工作表的列值。

我发现 'case' 语句是 tableau 中的一个有效函数,但我不确定我是否可以获得这种功能。基本上我只获得了“authorizedAction”,我需要为上述 4 种情况创建一个计算字段。我可以以某种方式将这些案例陈述分组到一个计算字段公式中吗?

任何帮助表示赞赏。如果你能给我一个有效的计算字段公式,那就没有了!

4

1 回答 1

1

在上面的 SQL 语句中,您有一个输入字段,该字段被拆分为 4 个输出字段,每个字段可能是“Y”或空白。您可以在 Tableau 中创建一组类似的 4 个计算字段,每个字段都有一个公式,如下所示

(field name)        (formula)
Add:                if ([authorizedAction] % 2) = 1 then 'Y' else '' end
Update/Display:     if (([authorizedAction] / 2) % 2) = 1 then 'Y' else '' end
Update/Display all: if (([authorizedAction] / 4) % 2) = 1 then 'Y' else '' end
Correction:         if (([authorizedAction] / 8) % 2) = 1 then 'Y' else '' end
于 2013-10-28T15:06:15.713 回答