Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comparing two histograms within the same chart in tableau

I have a histogram of my entire dataset that I want to compare to a histogram of a filtered subset of that data. I can do this in two separate sheets, and then show them side by side in a dashboard.

Is there any way to combine these two histograms into a single chart with common axes rather than two charts side by side?

like image 263
user148772 Avatar asked Nov 09 '22 07:11

user148772


1 Answers

There are several ways to approach this. Here's two:

First define a calculated field that returns any non-null value for rows that match your filter criteria, and no value at all (i.e. null) otherwise. In the example below, the calculated field is called Matches Department and is defined as if [Department] = [Department to Show] then 1 end where Department to Show is a parameter. Move the new calculated field to the Dimensions section of the data pane.

The first (easiest) solution is to make a histogram of Number of Records, and then place Matches Department on the Color shelf to get a stacked bar chart. stacked bar chart histogram

Here's a second variation, a bit more work to make a slightly different emphasis that may or may not be worth the effort to you.

Recall that the Count() aggregation function returns the number of rows that have a non-null value for its parameter. So CNT(Matches Department) returns the number of rows whose Department field matches the selected parameter.

So you can create a combo chart using CNT(Number of Records) and CNT(Matches Department) and then you can adjust the size on each measures marks card to show that one histogram is on top of the other. (Turn on dual axis, synchronize and then hide the second axis)

enter image description here

It looks pretty similar, but the red bars are actually narrower to emphasize that they are just a subset.

You could also make a bullet chart using the Show Me feature.

like image 180
Alex Blakemore Avatar answered Jan 04 '23 03:01

Alex Blakemore