0
votes

I am trying to get functionality as shown in the below SQL code:

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 ....

I want to represent all the 4 cases (Add, update/Display, Update/Display All and Correction) as column values for a worksheet in tableau.

I found 'case' statement is a valid function in tableau but am not sure if i can get this kind of a functionality. Basically I am only given 'authorizedAction' and I need to create one calculated field for the 4 cases above. Can I somehow group these case statements into one calculated field formula?

Any help is appreciated. If you can provide me a calculated field formula that works, nothing like it!

1

1 Answers

1
votes

In the SQL statement above, you have a single input field that gets split into 4 output fields, each of which may be 'Y' or blank. You can create a similar set of 4 calculated fields in Tableau, each one with a formula, along the lines of

(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