KNOWLEDGE BASE

How to calculate the total number of [Customer ID] for the rest of the categories within the current group.


Published: 23 Jun 2022
Last Modified Date: 23 Jun 2022

Question

How to calculate the total number of [Customer ID] for the rest of the categories within the current group?
data source: Sample Superstore

Environment

  • Tableau Desktop

Answer

1. Create a calculated field to calculate the total number of [Customer ID], for example, called: 'CustomerIDCountD', with the script:
COUNTD([Customer ID])

2. Create a calculated field to calculate the total number of [Customer ID] per group, for example, called: 'Customer Id CountPerGroup', with the script:
{ FIXED [Sub-Category (group)]:COUNTD([Customer ID])}

3. Create a calculated field to calculate the total number of [Customer ID] for the rest of the categories within the current group, for example, called: 'CustomerIDCountExceptCurrSubcategory', with the script:
ATTR([Customer Id CountPerGroup])- ([CustomerIDCountD])

Please refer to the attached workbook.
Did this article resolve the issue?