4 Replies Latest reply on Sep 22, 2016 5:10 AM by ra.sae.0

# Calculate the difference from 2 different worksheets and show the result set in a 3rd worksheet.

Hi,

I have a requirement where i have to create a snapshot report which has a current report with today's date and with yesterday's data as a separate report and calculate the difference between the reports and show as a separate report, as shown below.

Please let me know is this possible to do it in Tableau.

Can we calculate the difference from 2 different report and show the result set as a 3rd report.

Swetha

• ###### 2. Re: Calculate the difference from 2 different worksheets and show the result set in a 3rd worksheet.

Hi Swetha,

By looking at snapshot, I'd suggest create 3 worksheets in tableau; First will have filter on current date (with all the measures), second will have the yesterday's date filter and for 3rd  you have to create calculated fields for LOCS and SCREEN field. The calculated fields will have the difference calculation followed by logical expressions.

I don't have access to sample data and a tableau right now, otherwise I'd have gave you the sample workbook. But if you understood what I mean then you have something to carry on!

• ###### 3. Re: Calculate the difference from 2 different worksheets and show the result set in a 3rd worksheet.

Yeah this can be done! You've to create few calculated fields which calculates the measure values based on today and yesterday separately. Once we get the values for today and yesterday then we can get the difference from that. LOD expression will help you to achieve that. If you share a sample workbook in .twbx format then me or someone from community can give you solution.

Mahfooj

• ###### 4. Re: Calculate the difference from 2 different worksheets and show the result set in a 3rd worksheet.

Hi Swetha,

You cannot create a third report using data from two reports but there is a workaround.

Create the third sheet with calculated fields like the below or see attached file.

Today's Measure:

if DATETRUNC('day',[Date]) = DATETRUNC('day',TODAY()) then

[Measure 1]

END

Yesterday's Measure:

[Measure 1]

END

Difference's Measure:

sum([Yesterday's Measure 1]) - sum([Today's Measure 1])