Create a calculated field: -
if [Fund Only Choice] == 'Show All Stocks' then [Stock]
else if [Fund Only Choice] == 'Show Fund Only Stocks' then
if [Fund] != 0 then [Stock] end end end
Replace Stock from column with this field. Also put this field in filter section & exclude "Null".
This will work for you. I am using Tableau 8.1 & attaching a file here.
Filter Using Parameter.twbx 16.4 KB
I managed to get this working myself as well. It uses slightly different logic to above answers.
(1) You can use a boolean parameter and IIF style logic in a filter.
[FUND] = IIF([Fund Only Choice],0,[FUND]+1)
(2) or make the parameter a float with values 0 for Fund Only and 999 for All:
[FUND] != [Fund Only Choice]
You have to assume in both cases you know your data-set will never have 999
Boolean logic is usually faster in Tableau than IF statement, although I'm actually not sure which one of the 4 works best!
Thanks for your replies
Thanks for sharing your solution too!
Actually I think this is the best solution:
Step (1): Create a Boolean parameter named Fund Only Choice where True is aliased to Show Fund Only Stocks and False is aliased to Show All Stocks.
Step (2): Create a new calculated field named Fund Only Calculation:
IIF([Fund Only Choice],[Fund],0) != IIF([Fund Only Choice],0,1)
Step (3): Add Fund Only Calculation to the filter shelf and set to True
This method tries to use Boolean logic where possible to make it fast and avoids the problem of hard coding 999.
Filter Using Parameter.twbx 13.6 KB
And there's a further simplification:
Fund Only Calculation is even simpler if written:
NOT [Fund Only Choice] OR [Fund] != 0