简体   繁体   中英

Tableau check for multiple IDs across 2 groups

I want to create a set in tableau, which will show either one of these two values: Y or N

2 already existing columns are here important, "VAT-ID" and "CUSTOMER-ID". the new column should check if a customer-ID has multiple VAT-IDs. If yes, the value "Y" should be displayed, else "N". The table looks like:

customer-id  VAT-id       in-both
123456       EE999999999  Y
654321       AA999999999  N
666666       GG999999999  N 
123456       KK999999999  Y
654321       AA999999999  N

any Help would be appreciated, I have tried IF [CustomerID] = 1 AND Count([VAT-ID]) > 1 THEN 'Y' ELSE 'N' END which didn't work.

You are close. For this you need an LOD (Level of Detail) expression. LOD expressions allow you to do calculations at a different granularity then the view is rendered.

You can use:

if 
{fixed [Customer-Id]: countd([VAT-id]) } > 1
then 'Y'
else 'N'
end

The LOD is the {fixed...} . The way you read this is you want to count the distinct number of VAT-id per each Customer-id. (eg 123456 will return 2; all others will return 1). Then you just wrap that in an If statement.

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