Write calculated fields with LOD expressions, table calcs, and sets
✓Works with OpenClaudeYou are a Tableau calculation expert. The user wants to write calculated fields using LOD expressions, table calculations, and sets to solve aggregation and comparative analysis problems.
What to check first
- Open the Tableau workbook and navigate to Analysis > Create Calculated Field or right-click a dimension/measure in the Data pane
- Verify your data source has the dimensions and measures needed for the calculation (check the Data pane structure)
- Confirm whether you need row-level, aggregate, or LOD-scoped calculations by examining your current viz context
Steps
- Create a basic calculated field by clicking Create Calculated Field and naming it (e.g., "Sales per Customer")
- Write a FIXED LOD expression using
{FIXED [Dimension] : SUM([Measure])}to aggregate at a specific dimension level, ignoring viz filters - Write a EXCLUDE LOD expression using
{EXCLUDE [Dimension] : SUM([Measure])}to remove one dimension from aggregation scope - Write an INCLUDE LOD expression using
{INCLUDE [Dimension] : SUM([Measure])}to add a dimension to the aggregation scope - Create a table calculation by writing
SUM([Sales]) / TOTAL(SUM([Sales]))to compute percentages or running totals within partitions - Use the PARTITION BY and ORDER BY clauses in table calcs:
RUNNING_SUM(SUM([Sales])) PARTITION BY [Region] ORDER BY [Date] - Create a set-based calculated field using
IF [Customer] = [Set Name] THEN 'In Set' ELSE 'Not In Set' END - Validate the calculation by dragging it to a shelf and checking for aggregate vs. dimensionless behavior
Code
// LOD Expression: Total Sales per Customer (FIXED)
{FIXED [Customer ID] : SUM([Sales])}
// LOD Expression: Sales excluding current Product (EXCLUDE)
{EXCLUDE [Product] : SUM([Sales])}
// LOD Expression: Add Sub-Category detail to Region aggregation (INCLUDE)
{INCLUDE [Sub-Category] : SUM([Sales])}
// Table Calculation: Percent of Total Sales
SUM([Sales]) / TOTAL(SUM([Sales]))
// Table Calculation: Running Sum by Region and Date
RUNNING_SUM(SUM([Sales])) PARTITION BY [Region] ORDER BY [Date]
// Table Calculation: Rank within each Segment
RANK([Sales]) PARTITION BY [Segment]
// Set-Based Calculated Field: Flag Top Customers
IF [Customer ID] = [Top 10 Customers] THEN 'Top' ELSE 'Other' END
// Set-Based Calculated Field: Member Check
IF [Region] = [High-Value Regions] THEN 'Included' ELSE 'Excluded' END
// Composite Calculation: Average Sales per Customer (LO
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Tableau Skills
Other Claude Code skills in the same category — free to download.
Tableau Dashboard
Build interactive dashboards with filters, parameters, and actions
Tableau Data Prep
Clean and transform data with Tableau Prep Builder flows
Tableau Server Admin
Administer Tableau Server with sites, projects, and permissions
Tableau REST API
Automate Tableau operations with REST API and Hyper API
Tableau Extensions
Build dashboard extensions with Tableau Extensions API
Tableau Dashboard Performance Tuning
Speed up slow Tableau dashboards by fixing the most common performance killers
Tableau Extract Best Practices
Configure Tableau extracts for fast queries and efficient refresh
Want a Tableau skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.