4 Replies Latest reply on Aug 26, 2014 2:30 AM by andrewvincent.yap

# How to make histograms for complex table calculations?

Hi all,

I've been trying to find a discussion on making histograms for calculated fields with complex table calculations (i.e. values of the fields are dependent on the presence of other grouping fields). Unfortunately, most discussions are about histograms of calculated fields that do not require table calculations.

My problem:

I was able to create a table that looks like this in Tableau:

The Days Diff field has the following formula:

IF INDEX() > 1

THEN DATEDIFF('day', LOOKUP(MAX([Date]),-1), MAX([Date]))

END

and uses the following table calculation:

Note: [Index] = INDEX()

I want to make a histogram of the Days Diff field. I will be using this for a dashboard that filters by product and customer name. If, for example, I select Product Name = Awesome Product and Customer Name = Jane Doe, then the histogram for the values (6, 5, 2, 5, 7) should appear.

Unfortunately, I cannot obtain values for Days Diff unless I create the table above. This prevents me from creating a histogram because of the presence of the Product Name, Customer Name, and Date fields.

Is there any workaround for this without having to export data? Any help will be appreciated.

Thanks,

Andrew

• ###### 1. Re: How to make histograms for complex table calculations?

Hi Andrew,

Not certain if I understand you correctly, but have a look if the attached sparks some ideas. I believe if you google "binning by aggregate" or check this wonderful workbook of Jonathan Drummey you will get to the answer of your question.

• ###### 2. Re: How to make histograms for complex table calculations?

Thank you for replying. Your sheet "what you have" is correct. That is the format of data I have. What I want, however, is something closer to Jonathan Drummey's graph, but using a different type of calculation.

What I am looking for is something like this:

I want to be able to convert the table of data shown above into the histogram shown below. I cannot select the histogram chart option in Tableau because the histogram option only works if you have only 1 measure selected. In this case, I have 1 measure and 3 dimensions (Category, Customer Name, Order Date).

I have re-attached your twbx file for your reference.

Once again, thank you for your time.

Best regards,

Andrew

• ###### 3. Re: How to make histograms for complex table calculations?

Is this a bit closer?

• ###### 4. Re: How to make histograms for complex table calculations?

Yes, this is perfect! I didn't know you could move the other dimensions to the marks card without affecting the calculation. Thank you very much!

Andrew