Search code examples
sumtableau-apisumifs

Sum Distinct Category and Value


I have the data from SQL like below

Adviser | ProductProvider | NumberPolicyLapsed |Status |
--------|-----------------|--------------------|-------|
A       |ANZ              |3                   |New    |
A       |ANZ              |3                   |Ongoing|
A       |ANZ              |3                   |Out    |
A       |AXA              |4                   |New    |
A       |AXA              |4                   |Ongoing|
A       |AXA              |4                   |Out    |
A       |Zurich           |5                   |New    |
A       |Zurich           |5                   |Ongoing|
A       |Zurich           |5                   |Out    |      

How do I tell Tableau to read the distinct Adviser, distinct ProductProvider, and distinct NumberPolicyLapsed to sum up the column NumberPolicyLapsed? So basically for Adviser A, the Number of Policy Lapsed will be 12 (3 + 4 + 5).

So far, I have tried

  • Using SUM(NumberPolicyLapsed) and the result is 36 (3+3+3+4+4+4+5+5+5).
  • Using LOD {Fixed [Adviser],[ProductProvider] : SUM (NumberPolicyLapsed)} and the result is way bigger than 36.
  • Using Window_Sum (NumberPolicyLapsed) after re-constructing the table without status but it doesn't work.

I'm using Tableau Desktop 10.0.

Thanks.


Solution

  • GOT IT !!!! =D. By using the LOD. However, instead of SUM, I need to use MAX since the number are all the same. The LOD will pick up one maximum value that belong to specific adviser and specific ProductProvider.

    For example, for Adviser A and ProductProvider ANZ, Tableau will be picked up the maximum number of 3. And so on for the other specific ProductProvider. Put that LOD into Text marks and it will sum up the result. Below is the syntax.

    {Fixed [Adviser].[ProductProvider] : MAX (NumberPolicyLapsed)}

    Thanks all for your help.