Hi Zahid, you can do this with parameters. Create a parameter (let's call it [Selector]) that allows a list of strings, and allow values like "<", "=", etc. Then, you'll need two other parameters for the values you'll be comparing against. Let's call those [V1] and [V2].
Then, you can create a calculated field for filtering like so:
WHEN "<" THEN [Whatever Field] < [V2]
WHEN "<=" THEN [Whatever Field] <= [V2]
WHEN "<" THEN [Whatever Field] > [V1]
WHEN "<=" THEN [Whatever Field] >= [V1]
WHEN "!=" THEN [Whatever Field] != [V2]
WHEN "Between" THEN [Whatever Field] > [V1] AND [Whatever Field] < [V1]
Thanks for your prompt reply, Could provide a real world example to co-relate above CASE statement. By taking into account sample Employees and department table. How would above look like?
I need to filter only employees earning between 5000 and 7500
and then Employees earning 3000 (exact amount) and so on
Once again thank you for your reply
You would replace [Whatever Field] with [Employee Salary] or whatever the field's name is.
For the first example, you would set V1 to 5000, V2 to 7500, and Selector to "Between".
For the second example, you would actually need to add another line into the code for equals, but then you would pick "=" in Selector and put 3000 into V1 or V2, whichever you choose to use.
I did try to implement your suggestion. However, tableau says "CANNOT USE BOOLEAN TYPE IN CASE EXPRESSION". Below is the code for calculated field
WHEN "<=" THEN [Amount] <= [Amount To]
WHEN ">=" THEN [Amount] >= [Amount To]
WHEN "=" THEN [Amount] = [Amount From]
WHEN "Between" THEN [Amount] > [Amount From] AND [Amount] < [Amount To]