2 Replies Latest reply on Apr 17, 2018 6:12 PM by Daniel Oh

# Market share calculation - Difference between specific date

Hi all!

I have question for creating measure - market share difference between specific dates.

There is data for sales per each product & region & date.

To calculate market share, I used level of detail as below

SUM([Sales]) / Min({FIXED [Date],[Region] : SUM([Sales])})

Result :

And then to compare M/S Difference between 2018-01-04 vs 2018-01-01 I used 'If' function but tableau throw errors due to aggregation

Expected Result - A : -27.0%  / B : 55.6% / C : -28.6%

Under this situation, I tried to use 'ATTR" or any other solution(e.g. table calculation) but I can't get the perfect result.

If I use Table Calculation(Lookup) and Index I can get expected result but I can't use table calculation as filter or sort to pick Top1 Product or Top1 Region.

• ###### 1. Re: Market share calculation - Difference between specific date

Good morning

see the attached -

In your formula there is a logic issue - a date cannot be 2018 01 04 AND 2018 01 01 so you won't get the difference between the 2

this will work

and it returns this

Jim

If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

• ###### 2. Re: Market share calculation - Difference between specific date

Hi Jim,

I tried this way before, but it can't be used by filter

Can you apply filter on 'Product' to pick Top 1 Product by using 'difference formula'?

Due to characteristic of table calculation, it doesn't work..

I want to display Top 2 Product in Top 1 region based on M/S difference between 1/1-1/4.