Tableau实时连接数据源下,如何基于行内双条件筛选符合权限要求的用户并展示数量
Got it, let's work through this Tableau problem step by step—since you're stuck with a live connection and can't modify the source data, we'll use calculated fields to get around the filter conflict you're seeing.
Step 1: Create Calculated Fields to Flag Eligible Users
The key here is to evaluate your two conditions at the user level (not row level), since permissions are likely stored as separate rows per user. Let's build three calculated fields:
1.1 Flag for "Worldwide Global access"
Make a calculated field (name it Has Global Access) with this logic:
[Permission] = "Worldwide Global access"
This returns True for any row where the user holds this permission.
1.2 Flag for Valid "Worldwide Region access"
Create another calculated field (name it Has Valid Region Access) with:
[Permission] = "Worldwide Region access" AND [Region] = "ALL" AND [Sub region] = "ALL"
This only returns True when the user has this region permission and both region columns are set to "ALL".
1.3 Combine Conditions to Identify Eligible Users
Now we need to check if a user meets both conditions across all their rows. Make a calculated field named Eligible User with:
{ FIXED [User] : MAX([Has Global Access]) } = TRUE AND { FIXED [User] : MAX([Has Valid Region Access]) } = TRUE
The FIXED LOD expression looks at every row for a single user and checks if they have at least one row matching each condition. This avoids the conflict of separate filters, which would exclude rows that don't match each filter's criteria.
Step 2: Apply the Filter
- Drag the
Eligible Userfield to the Filters pane. - Select
Truefrom the filter options. This will only retain users who meet both your requirements (in your case, only user "AAAA").
Step 3: Build Your Bar Graph
Now you can:
- Drag
Userto the Columns shelf - Drag
CNTD(User)(count of distinct users) to the Rows shelf
You'll get a bar graph showing only the eligible user, exactly what you need.
Why This Beats Separate Filters
Separate permission filters work at the row level—so when you filter for "Worldwide Global access", you exclude all rows with the region permission, and vice versa. The LOD expression lets us evaluate the user's entire set of permissions, ensuring we capture anyone who has both required access types.
内容的提问来源于stack exchange,提问作者user3186707

