0 votes
1 view
in BI by (16.3k points)

I want to aggregate bins in tableau.

See the following figure: 

Data in Tableau

I want to aggregate (merge) the NumberM from 6 untill 16 in one category. 5+/(6 and higher) for example and sum the values of 6-16 in that category. I think this can be done with a few simple clicks but I am not able to manage.

Thanks in advance

1 Answer

0 votes
by (43.4k points)

In order to classify data rows into different groups or classes, there are several ways: each with different strengths.

  • Create a calculated field. One approach is to create a calculated field to assign a value to a new field indicating which group each data row belongs to. For the effect you want, the calculated field should be discrete (blue). For suppose, your calculation doesn't return a value for in one case, e.g. an if statement without an else clause, then the field will be null in that case which is a group in itself. This is a very general approach and can handle much more complex cases. The only downsides are the need to maintain the calculated field definition and that the cutoff values are hardcoded and by itself can't be changed dynamically via a control on the view. BUT those issues can be easily resolved by using a parameter instead of a numeric literal in your calculated field. In fact, that's probably the number one use case for parameters. If you think in SQL, a discrete field on a shelf is like a group by clause.

  • Use a filter If you only want a subset of the data in your view, e.g. data rows with NumberM in [6, 16] then you can drag the NumberM field onto the filters shelf and select the range you want. You have to note for continuous (green) numeric fields, filter ranges include their endpoints. Filters are very quick and easy to drop on a view. By right clicking on them and creating a quick filter, they can be made dynamically adjustable. Now, It's obvious from the view that a filter is in use and the caption will include the filter settings in its description. But a filter does not let you define multiple bins. If you think in SQL, a filter is like a where clause (or in some cases using the condition tab, like a having clause)

  • Define histogram bins If you want to create regular sized bins to cover a numeric range, such as values in [1,5], [6,10], [11-15] ..., Tableau can create the bin field for you automatically. You need to just right click on a numeric field, and select Create Bins.

  • Define a group that would be very useful for aggregating discrete values, such as string fields, into categories. Good for rolling up detail or handling multiple spellings or variants in your data. Just right click on a field and select Create Group. Or you can select some discrete values on an axis or legend and press the paperclip option. If you then edit a group, you'll see what's going on. In case you think in SQL, a group is like a SQL case statement.

  • Define a set Another way to roll up values. The definition of a set can be dynamically computed or a hardcoded list of members. Both kinds are useful. You can combine sets with union, intersection, set difference operators, and can test set membership in calculated fields. For binary decisions, Sets are useful.  rows are divided into those that are members of the set and those that are not.

  • Sets, filters, groups, calculated fields, and parameters can often be combined to accomplish different effects.

  • Else all of these features can be implemented using calculated fields, especially if the business rules get complicated. But if a filter, bin, group or set fits your problem well, then it's often best to start with that, rather than define a calculated field for each and every situation. That said, learning about the 4 kinds of calculated fields really makes a difference in being able to use Tableau well.

Related questions

0 votes
1 answer
asked Jul 29, 2019 in BI by Ashok (43.4k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 20, 2019 in BI by Vaibhav Ameta (16.3k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...