简体   繁体   中英

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.

在此处输入图像描述

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.

在此处输入图像描述

I want my output to be like the one below.

在此处输入图像描述

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM