1
votes

I'm writing a calculated field in Tableau and I need to know if an option in a multiple filter is active to use it in an IF statement.

For example, I have the column [School Type] with a multiple filter that has the options "Elementary School", "Primary School" and "Secondary School". I need to do something like:

IF **[School Type] has active "Primary School"**
THEN
**Some calculation**
END

Does anyone know if this is possible?

Thanks!

1
Is it possible to share a little more detail about the expected output and/or example? (ie: does this calculated field result in a dimension or a measure? Is it something that you only want to appear if a certain few filter objects are selected? etc?) I ask because with some understanding of the underlying question, there might be an alternative way to accomplish. - MonteCarloSims
The original problem es this one: stackoverflow.com/questions/55654958/… I was trying to solve it with the suggestion that someone gave in the Tableau Forum and that's why I asked this question about filter. I finally solved the problem using LODs (exclude and include, specifically). But I left this question because it's an interesting topic that I might use in the future and would want to know. - dubafek
If the filters are active for the view then you don't need to include them in the calculation: the result will already be based on the calculation applied only to the filtered values. - matt_black

1 Answers

0
votes

You can't use a filter in calculated fields, For filter to get into effect you need to place that in filters ribbon, so the data you get in the sheet is in accordance to the filter selection.

Way out you have left is create a calculated field and use the database field in calculation.

if [School Type] = "Primary School"  //has active equlas **=**
then your caclulation
else your calculation
end