1 2 Previous Next 15 Replies Latest reply on Jul 29, 2016 8:10 AM by David Pires

How to calculate the difference of two charts and create a new chart

Hi,

Can anyone let me know how to How to calculate the difference of two charts and create a new chart?

Requirement:I have a Product Dimension with items as Product 1, Product 2.and i have created 2 Line charts. Now I need to create a 3rd line chart which is difference of the Product-1 and Product-2.

Thanks,

Samir

• 1. Re: How to calculate the difference of two charts and create a new chart

Hi Niranjan,

its just a measure difference for product 1 - product 2.

Can you share the sample data?

-Ashish

• 2. Re: How to calculate the difference of two charts and create a new chart

HI Ashish,

If you can guide me on this.The sample page i created is

• 3. Re: How to calculate the difference of two charts and create a new chart

Hi Niranjan,

First of all I would like to tell you that you have data with bad shape. Those month should be come under single dimension and not like the way you have. (You have sales for every month as a column which means this data isn't normalized)

Still in Your case you can write something like this.

Calc1

If [ProductName]="Product1" then Max(Jan-15)

end

Calc2

If [ProductName]="Product2" then Max(Jan-15)

end

Calc Diff

[Calc1]-[Calc2]

So you will have to create a calculated field for each and every month which is not a good idea. (like you will have to do it for Jan-15, Feb-15, March-15 etc..........)

It would be great if you ask your team to help you with getting data in shape. Trust me, things will be very easy for you.

Thanks and Regards,

Ashish Chaudhari

• 4. Re: How to calculate the difference of two charts and create a new chart

Yes Ashish you are correct.But unfortunately due to huge data it wont be possible in excel to align all periods in one column.

Still trying your method but getting this error.If you can help me on this.

• 5. Re: How to calculate the difference of two charts and create a new chart

Instead of [Measure] you should have your [Category]. It looks like Tableau is giving you an error because you are asking for a string from an integer measure.

David

• 6. Re: How to calculate the difference of two charts and create a new chart

but my calculation demands Measure to be used.

I used Table Calculation(Difference from) to derive the required result but problem is in creation of line chart.

Any solution to it?

Screenshot below:

• 7. Re: How to calculate the difference of two charts and create a new chart

Sorry I misunderstood I thought your dimension was called [Category].

In order for Tableau to create an axis it requires a measure (green pill) to be placed on the rows or columns shelf.

Currently your [Measure Values] is showing as a label and despite the fact that you have asked Tableau to create a line chart. Tableau is unable to do so.

Drag measure values columns and measure names to detail that should do it.

David

• 8. Re: How to calculate the difference of two charts and create a new chart

Yes but my Quick table calculation is dependent on Category & Measure as shown in Rows.

If i drag the Measure values to row it is showing Blank.

Please let me know if my approach is wrong.

• 9. Re: How to calculate the difference of two charts and create a new chart

Even if category and measure are added to detail?

Can you post a workbook, it will be pretty difficult otherwise.

David

• 10. Re: How to calculate the difference of two charts and create a new chart

Hi David as requested sharing the Workbook.

• 11. Re: How to calculate the difference of two charts and create a new chart

I'll have a look.

Niranjan what's the original data source you are using? Excel?

• 12. Re: How to calculate the difference of two charts and create a new chart

Yes David.

• 13. Re: How to calculate the difference of two charts and create a new chart

Oh I'm so sorry I should have asked this before.

You can use Tableau's own interpreter to pivot your data and make it shape the way you want. It will save you hours. Read this:

and this

and this as well.

Essentially what that will give you is the ability to group your values and categorise them into each month therefore you will only need 1 measure field and your date will be a dimension.

It should be straightforward but if not, attach a spreadsheet in that format and I'll do a quick video of the Tableau interpreter working its magic.

David

• 14. Re: How to calculate the difference of two charts and create a new chart

I understood David what you are trying to say.

But unfortunately, we have huge data and almost the spreadsheet's all rows getting updated.

Any alternate way to solve it.

1 2 Previous Next