2 Replies Latest reply on Jan 21, 2014 10:02 PM by John Kanady

# Trying to subtract histograms from each other

Hello!

I have a set of data that I've plotted in histogram form.  I applied a quick table calculation to express the frequency values as a percent of total (for relative frequency values).  What I'd like to do from here is to subtract the two resultant histograms from each other.  Using the "Difference" quick table calculation will do it nicely for the absolute counts, but I'm not sure how to do it for the relative (percent of total) frequency.

Essentially, I'd like to apply first the percent of total calculation and then the difference calculation.  I've tried creating a calculation that combines the two functions for what I want, but I'm not having any success ("Relative frequency difference" calculation in the workbook).

I've attached a picture (done outside Tableau using image overlays) to give an idea of what I'd like to achieve within Tableau.   The blue plot is subtracted from the orange plot.

Any help would be greatly appreciated!

• ###### 1. Re: Trying to subtract histograms from each other

Hello John,

I have attached a revised version of the workbook provided which demonstrates how to create the desired view.

In order to build the view, I have separated the CNT(Adjusted Tau) table calculation into two separate calculated fields (one for each Genotype) using the formulas below:

(Both table calculations were set to Compute Using > Adjusted Tau (bin))

I then created a new calculated field with the following formula:

This calculated field is also a table calculation, and its Compute Using settings are set as shown in the screenshot below:

Then I created a final calculated field to color the bars based on whether they were negative or positive:

Finally, all three table calculations were dropped on to the Rows shelf, and the color calculated field was placed on the Color shelf for the difference calculation.

Hope this helps!

- Jordan

• ###### 2. Re: Trying to subtract histograms from each other

Absolutely fantastic!  Thank you kindly, Jordan!  It was driving me batty trying to find a method to make it work.

Very much appreciated,

- John