Tableau钻取视图中CNTD(字段)仅显示1而非正确行数的技术求助
Troubleshooting
CNTD(项目ID) Returning 1 Instead of 11 in Your Drill-Down View Hey there! Let's break down why your count distinct is giving you an unexpected 1 instead of the 11 projects you see in your cardiovascular specialty solution list. Here are the most common fixes to check:
1. Verify Project ID Uniqueness Across Your 11 Projects
First, double-check the actual values in your 项目ID field for those 11 projects. It’s easy to miss:
- Are there hidden duplicates? For example, maybe all 11 rows share the exact same project ID (even if the project names look different). You can add the
项目IDas a row in your view to confirm each project has a unique ID. - Check for format inconsistencies: Trailing spaces, uppercase/lowercase differences, or special characters might make IDs look unique but are actually identical. Use a calculated field like
TRIM(项目ID)to clean up whitespace and testCNTD(TRIM(项目ID))instead.
2. Check Your View’s Aggregation Level
Since you’re drilling down from a pie chart, make sure your view isn’t aggregating at a higher level than individual projects:
- If your row/column shelves only include the "心血管专科解决方案" segment (and not
项目IDor项目名称), your tool will calculateCNTD(项目ID)at the segment level. If the segment only has one unique ID (even if you see 11 rows due to other data joins), that’s why you get 1. - Add
项目IDor项目名称to your row shelf to ensure the view is broken down to individual project rows, then recheck theCNTDvalue.
3. Rule Out Data Join/Blending Issues
If you’re using multiple data sources:
- A one-to-many join might be causing the same project to appear multiple times in your list (making it look like 11 projects, but they’re actually duplicates of one unique ID). Use a
COUNT(项目ID)instead ofCNTDto see if you get 11—if yes, your data is being duplicated via joins. - Check if any filters are silently excluding unique IDs: Context filters or data source filters might be limiting the scope of your
CNTDcalculation. Temporarily remove all filters to see if the count updates correctly.
4. Validate the Calculation Context
- Make sure your
CNTD(项目ID)calculation isn’t wrapped in any level of detail (LOD) expressions that force aggregation at a higher level. For example, a fixed LOD like{FIXED [细分领域]: CNTD(项目ID)}would only count unique IDs per segment, which might be 1 if your data has an issue. - Test with a basic
COUNT(项目ID)first: if that returns 11, it confirms that项目IDis duplicated across the 11 rows, andCNTDis correctly counting unique values (which is 1 in that case).
Start with these checks—they’ll almost always uncover why your distinct count isn’t matching the number of rows you see!
内容的提问来源于stack exchange,提问作者Waqar Ahmad
相关产品推荐
相关产品推荐

