Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (17.6k points)

I am trying to create a graph with two lines, with two filters from the same dimension.

I have a dimension that has 20+ values. I'd like one line to show data based on just one of the selected values and the other line to show a line excluding that same value.

I've tried the following: -Creating a duplicate/copy dimension and filtering the original one with the first, and the copy with the 2nd. When I do this, the graphic disappears. -Creating a calculated field that tries to split the measures up. This isn't letting me track the count.

I want this on the same axis; the best I've been able to do is create two sheets, one with the first filter and one with the 2nd, and stack them in a dashboard.

My end-user wants the lines in the same visual, otherwise, I'd be happy with the dashboard approach. Right now, though, I'd also like to know how to do this.

1 Answer

0 votes
by (47.2k points)

  • It is a little hard to tell exactly what you want to achieve, but the problem with filtering is common.

  • The most important principle in Tableau is that it will filter the whole dataset by row. So duplicating the dimension you want to filter won't help as the filter on the original dimension will also filter the corresponding rows in the second dimension. Any solution has to be clever enough to work around this issue.

  • One solution is to build two new dimensions that use a calculation rather than a filter to create the new result. Let's say you have a dimension, [size] that has a range of numbers from 1 to 10 and you want to compare the total number of rows including and excluding the number 5. You could create a new field using a formula like if [size] <> 5 then 1 else 0 end

  • Summing the new field will give a count of the number of rows that don't contain a 5 and this can be compared directly to a row count of the original [size] field which will give the number including the value 5.

  • This basic principle can be extended to much more complex logic. The essential point is to realize that filters act on every row in your data and can't, by themselves, show comparisons with alternative filter choices on a single visualization.

  • Depending on the nature of your problem there may be other solutions worth looking at including sets and groups but you would need to provide more specific details for users here to tell you whether they would be useful.

I would recommend sign up for Tableau Desktop Certification classes from Intellipaat, they will also help you get a job. 

Browse Categories

...