8 Replies Latest reply on Aug 30, 2019 10:41 AM by John Smith

# Calculate difference between 2 work sheet

I have one data source with two different dates. I need to take Transaction count from both dates and then calculate difference between two counts.

• ###### 1. Re: Calculate difference between 2 work sheet

That sounds fairly straight forward.

You can use Fixed LODs if the dates are actually two separate dimensions. If the dates are consecutive you can use 'difference from previous' table calculation. And the Lookup() function may be an option depending on what the table view looks like.

Do you have anything you can post?

• ###### 2. Re: Calculate difference between 2 work sheet

Thank you John, I am new to Tableau. I have been using Tableau since 3 months now. I have added spreadsheet here for your reference. Spreadsheet contain three sheets. First sheet with Charge back count and second sheet with Transaction count.

Third sheet shows what I would like to achieve. The formula to calculate % is (charge back count/transaction count).

FYI -- All data comes from one data source.

• ###### 3. Re: Calculate difference between 2 work sheet

Thanks for the worksheet. This is no problem. First you would join the two sheets on date. I removed the grand totals from your worksheet prior to uploading into Tableau.

Then I just used Transaction date since it was more complete and called it 'Date'.

Then Just drag the two count to the viz, right click on each and click on discrete.

Then create a calculated field just like you did in Excel. Drag it to the Viz and again right click and click on discreet. Here is a link to the workbook posted:  Tableau Public

• ###### 4. Re: Calculate difference between 2 work sheet

John thanks for the reply. Unfortunately I can not connect two sheets and create calculated filed because all fields (data) are coming from one data source. I just created two sheets to show you how I would like to see the result.

• ###### 5. Re: Calculate difference between 2 work sheet

Hello Zankhana,

I am using the sample super store as example to answer your qns. Please let me know if this is something you are looking for?

LOD for Distinct Counts based on Order Date

LOD for Distinct Count based on Shipping Date

Difference between the Counts

Thanks

Rekha

• ###### 6. Re: Calculate difference between 2 work sheet

Rekha thank you for quick reply. I can work with this solution if I can add date filter for the result. The issue is I am not able to combine two dates and create one date which user can use to filter the data.

• ###### 7. Re: Calculate difference between 2 work sheet

You can use a parameter and create a calculated field in each data source and control multiple date fields with a single parameter.

• ###### 8. Re: Calculate difference between 2 work sheet

Rekha,

When you select Number of Orders Based on Shipping Date year 2015, in the 1,703, you have units with Order Date in it as well., I think the problem is that you run columns by Order Date. Same if you run columns by Shipping Date. I am not sure how to do this the right way. Yes, one can separate Order Date and Shipping Date into the 2 worksheets, but I do not know, if Tableau can combine 2 results from 1 worksheet.

I have been trying to resolve this, but so far have not find a solution. Have you?

Thanks

John