Joseph Dollison
Joseph Dollison

Reputation: 1

Is there a way to count distinct number at granular level to aggregate level with multiple condition in tableau?

I have a situation wherein I want to count the distinct customer.in a table with a condition per product. I want a summary count of distinct customers per product.

I created a parameter which shows what I want to be included and what should not be counted. The rules applied on the status are written below:

IF ATTR([Product]) = 'A' AND COUNT([Record]) >= 10 THEN 'Should be counted'
 
ELSEIF ATTR([Product]) = 'B' AND COUNT([Record]) >= 5 THEN 'Should be counted'
 
ELSEIF ATTR([Product]) = 'C' AND COUNT([Record]) >= 3 THEN 'Should be counted'
 
ELSE 'Should not be counted'
 
END

Since the data is transaction per row. Think of record as purchases. I am only interested in the right side of the crosstab CountD column. Please refer to the image below.

enter image description here

How can I achieve a summary using distinct customers per product considering only repeat purchases for product A >=10, product B>=5 and product C>=3.. If I remove the customer name everything will be aggregated and undesirable.

enter image description here

I want my output to be like the one below.

enter image description here

Any help will be so much appreciated. Can someone share/teach me the steps to achieve the kind of output that I desire.

Thank you in advance

Joseph

Upvotes: 0

Views: 428

Answers (1)

AnilGoyal
AnilGoyal

Reputation: 26218

Though it would have been better if you'd shared the data structure, yet I think the following calculated field may help

{FIXED [Product] : COUNTD([CUSTOMER])}

Needless to say, If you want counting of filtered records, you should include [STATUS] field on filters shelf and Add to Context after right clicking it in the filters shelf itself (because order of operations of LOD calculations is higher than normal filters but lower than context filters)

Upvotes: 0

Related Questions