Isn't your SQL the same as:
SELECT A FROM table1 WHERE B IN ("some","static","values")
If yes, then it is a simple filter set-up.
seems like I messed up my example when trying to simplify it. Sorry for that. Actually it is:
SELECT * FROM table1 WHERE A IN (SELECT DISTINCT A FROM table1 WHERE B IN ("some","static","values"))
So only the part in the subquery wouldn't be enough.
I've attached an Example in an Excel Sheet:
Because Denmark (A) has at least one "Andrea" (B) and France (A) has at least one "Thomas" (B), all datarows having Denmark and France should later be displayed.
SELECT * FROM table1 WHERE A IN (SELECT DISTINCT A FROM table1 WHERE B IN ("Andrea","Thomas"))
ExampleSQL2Tableau.xlsx 11.0 KB
1 of 1 people found this helpful
I might be completely misinterpreting what you're trying to do but it sounds like you want to apply a late filter - so all date is shown for a dimension as long as part of it meets a specified condition. Does this article about applying late filters to tableau dashboards help?
If not I suggest you attach a packaged workbook.
The quickest hack I can think of is to use custom SQL in your connection.
See attached workbook for two solutions with Excel data source. If you data is not in Excel, then you need to translate SQL into whatever you have.
The idea is to do an outer self-join to your sub-query, which will test each row of your data against your sub-query criteria and create an extra column with Yes/No for each row. Simple filter does the rest.
In the attached example Custom SQL 1 is quick and crude, while Custom SQL 2 is a bit more "elegant".
Subquery via custom SQL.twbx.zip 89.7 KB
Thanks both of you for the quick response!
@Andrew: This is very helpful for another issue I have: To hide specific lines of a graph after a result is displayed (hide all values not within a +/-5% range from average to exclude strange peaks).
However, for this specific issue I cannot go this approach, as my values (% Difference) should change depending on if I include all countries or just the filtered countries.
@Dimitri: I think, that's what I was looking for. Thank you very much! Solution 2 from your workbook provides me exactly the filter I wanted to have.