Barring the introduction of IN and it's negation function (EXCLUDES? NOTIN?), this does the job cleaner than the repetitive recoding of "(encode_type_id =..." above:
field: encode_type_match CASE [encode_type_id] when 3 then "y" when 70 then "y" when 97 then "y" when 129 then "y" when 166 then "y" when 325 then "y" ... else "n" END
Using an IN expression would reduce the amount of syntactic sugar in the expression, but the CASE statement isn't too bad, whipping it up from a list of values is straightforward in modern text editors.
Also, the expressions you provided are not equivalent, the second has the
AND status_code = 200"
clause, which the first lacks.
Adding this clause is ambiguous; it's unclear what the intended scope of the AND is, and in any case Tableau chokes on the second expression with the error message: "Can't compare string and integer values".
Assuming I've guessed your intention correctly, combining the tests into a single logical evaluation is straightforward, using the results of the first inclusion expression in a second calculated field's expression like so:
field: type & status match if ([encode_type_match] == "y") and ([status_code] == 200) then "true" else "false" end
I'm attaching a twbx using the sample Superstore Sales data with examples of the
type & status matchfields.
innotinexamples.twbx 344.4 KB
True- I left out the AND status_code = 200 by accident, and I cannot edit the OP. Thanks for this technique, though. It'll certainly help when I revisit these fields - much easier to look at.
I think you've assumed my intention all right. I would then count the "true" values from
type & status matchas
confirmed downloads. Something like
IIF([type & status match = 'true'], 1, 0)
The further intention would be to have an exclusionary count, as well - an "All Others Field" or similar.
Yes PLEASE! I was just lamenting the lack of this the other day. My solution for some groups was using COMTAINS, which does the trick:
CONTAINS("TEES TESP TESC TESS TESD TECB TECC TECX TEUD TELDT APPR", [Work Group]) - the spaces makes them sort of discrete items in a list.
What I would like is to be able to use the groups/set that one can setup - ideall I want to interrogate ApplicableWorkGroups (a group) and see if a given group is part of it, rather than only being able to filter and whatnot on them.