0

I am attempting to create a flag in Tableau. I have rules that are created for tables that are running daily. The rules have a column that identify the category of rule for example RC001, DC001, FC001. I want to look at what rules run for the most recent day, and create a flag that says if rule types (RC001 OR RC003) AND DC001 AND NC001 AND (FR001 OR SC001) AND SL001 all ran then I want to give it a value of 1 else 0. Eventually I want to turn this into a visualization to show what percentage of tables aligned to a particular domain are checking all of the rule types and which are not.

I tried creating a flag, but I am very novice, and have no idea what I am doing in Tableau. Here was one of my attempts at this which just throws me a syntax error. Not sure how to program this. Maybe I need a parameter? Not sure.

CASE
WHEN
[Rule Type Id]=((RC001 OR RC003) 
AND NC001
AND DC001
AND (FR001 OR SC001)
AND SL001)
THEN 1
ELSE 0
END
jarlh
  • 42,561
  • 8
  • 45
  • 63

2 Answers2

0

For building a boolean calculation in Tableau Desktop you need to use the IF function. For the flag you want to build, the calculation will be:

IF ([Rule Type Id] = RC001 OR [Rule Type Id] = RC003) 
AND [Rule Type Id] = NC001
AND [Rule Type Id] = DC001
AND ([Rule Type Id] = FR001 OR [Rule Type Id] = SC001)
AND [Rule Type Id] = SL001
THEN 1
ELSE 0
END
0

Two quick things.

  1. CASE statements in tableau only support a single check, you cannot do the ANDs you are trying to do:

    CASE WHEN THEN WHEN THEN ... ELSE END

  2. Federico is correct that an If statement would work, but I would prefer to have a calculated field return true/false instead of 1/0. You can accomplish this by just doing the logic (no IF/ELSE/END). Your logic shown doesn't make sense though. How can a rule type be both (RC001 OR RC003) AND NC001? Please revise or tell us what you are trying to do, and I can provide an example.