Nicholas
Nicholas

Reputation: 1

Tableau: How to create a filter based of 3 different columns?

How to create a filter based of 3 different columns? Hello, I am new to Tableau so I appreciate any help or guidance along this journey.

I am currently facing an issue in which I need to build a filter that takes 3 columns into account and based on the interactive filter selection the chart should then displays the data accordingly. For example, this is my table structure:

Region | Sales_upper | Sales_lower | Sales_avg
A.     | 100.        | 70          | 80
B.     | 130.        | 60          | 100
 

This is my goal: I want to display my sales data by region and have a filter available called 'SALES' as a radio button under which I can choose either 'Sales_lower', 'Sales_upper', or 'Sales_avg'. If I select 'Sales_upper', the data should only filter for the first two columns, i.e. Region[A,B], Sales_upper[100;130].

How would I realize this solution?

Upvotes: 0

Views: 1203

Answers (1)

AnilGoyal
AnilGoyal

Reputation: 26218

You use case is not correct for filters.

See, filters are used to subset the data row-wise and not column wise. Say if your data contains 1000 rows and 10 columns/fields and you want the result to be calculated on some 500 rows (filtered on the basis of some criteria applied on a column/field) you have to FILTER the data. The Filter will result in 500 rows x 10 columns.

For displaying (read selecting) some of the fields, you have to choose fields to add in the view. Say, in the above example, if you want to show/select 5 columns then you just need to select those five columns(read fields) in the view.

If you want to show 500 rows x say 5 columns of your data, then you need to apply both.

Now, Fields (columns) are of two types in Tableau (Dimensions and Measures) further divided into two sub-categories each (continuous and discreet). If you select/add dimension fields to a view, all the values(unique) are displayed. If you select any measure field to view, instead of adding all measure values, these are aggregated instead (by default sum).

In your example, if you add only sales_upper to view, the values will be aggregated automatically and 230 will be displayed instead of two separate values (100 and 130). If you have to show these as two different values you have to convert the field to dimension (after which you cannot aggregate the field).

To let the user add his/her desired field to a view, you may use parameters in tableau, wherein you can add a parameter with values you desire to add. Thereafter you can map your measures to that parameters with a calculated field.

For adding cascading filters in tableau you'll have to set hierarchy on the desired fields in tableau, but again that won't fit in you use case because it will apply filter to the dimension values (added in the hierarchy) instead of first dimension values and then dimension names as you desire.

EDIT/UPDATE As a possible workaround you can pivot your three sales field into two fields one named sales type having values sales upper, sales lower and sales avg. Another field will contain corresponding values. So whenever you'll add a filter (choose any one type) on sales type and add value field along with region you can achieve your desired view up to some extent. See the following screenshots

enter image description here

enter image description here

Note that column names have to be converted to row values for applying FILTER to these

Upvotes: 1

Related Questions