6 Replies Latest reply on Jan 31, 2018 9:59 PM by parikshit.shinge

# Difference of sales between 2 different dates

Hi All,

I have a weird requirement and I'm not able solve this.

Data Source 1:

Current year :

 Product Month Sales A Jan'18 100 A Feb'18 200 A Mar'18 150 A Apr'18 300

Data Source 2:

Previous year :

 Product Month Sales A Jun'17 50 A Jul'17 100 A Aug'17 75 A Sep'17 200

In Tableau, I need to show 3 tables:

1. Current Year

 Product Jan'18 Feb'18 Mar'18 Apr'18 A 100 200 150 300

2. Previous Year

 Product Jun'17 Jul'17 Aug'17 Sep'17 A 50 100 75 200

3. Difference

 Product - - - - A 50 100 75 100

This 50 is difference between first column of Current Year table and First column of Previous Year table. Similarly for 2nd, 3rd & 4th. The difference is based on the ordering of month columns. There are filters provided for months of previous year & month of current year. user may select any months in Current Year table & any months in Previous Year table. The difference should be dynamically calculated based on filters selection.

User wants to compare sales of any months from previous year with sales of any months from this year. This comparison should be based on ordering of months in both the tables.

If user select 4 months in Current year & only 2 months in Previous Year, then output should be like:

 Product Jan'18 Feb'18 Mar'18 Apr'18 A 100 200 150 300 Product Jun'17 Jul'17 A 50 100 Product - - - - A 50 100 NULL NULL

I thought one way would be to cross join these data sources and creating one-to-all mappings both ways but that would be tremendous data and I can't afford it. Can I do it using table calculations or any other way?

Any help would be appreciated.

Regards,

Parikshit

• ###### 1. Re: Difference of sales between 2 different dates

Regards,

Parikshit

• ###### 2. Re: Difference of sales between 2 different dates

I'll take a look at this...

Jonathan

• ###### 3. Re: Difference of sales between 2 different dates

I've got a solution, I need to do some cleanup before posting it, I'll get to that tonight or tomorrow.

Jonathan

• ###### 4. Re: Difference of sales between 2 different dates

Hi Jonathan,

This is really looking great.. Can you please attach the workbook so i can see what that awesome thing you have done ?

Regards,

Parikshit

• ###### 5. Re: Difference of sales between 2 different dates

Hi Jonathan,

Did you get a chance to clean this up?

Regards,

Parikshit

• ###### 6. Re: Difference of sales between 2 different dates

Hi Jonathan,

Did you get a chance to work on this?

Regards,

Parikshit