Skip to content

Explain a FIXED LOD from its actual grain.

Read each LOD’s grouping fields before dividing the results. This sample computes category share inside each region and shows the exact result cells.

Updated

Read locally in this browser.

↳sample.csvSynthetic sample

What share does each category contribute within its region?

The synthetic East region has 100 in Hardware and 100 in Services. West has 150 and 450. Each region has its own denominator.

“Explain the numerator and denominator of this FIXED ratio.”

Worked example · authored synthetic data

  1. Read the original fileUse the existing browser reader
  2. Check the definitionKeep the grouping and filter scope explicit
  3. Compute the resultUse the existing xmetric engine
  4. Review the evidenceRead the exact cells and query

Calculation or query in this example

{ FIXED [Region], [Category] : SUM([Sales]) } / { FIXED [Region] : SUM([Sales]) }

Exact sample file · Definitions and expected values

xmetricCategory share within Region

Opening the labelled sample…

Expected values from the labelled sample; the browser recomputes them.

GroupResult
EastHardware0.5
EastServices0.5
WestHardware0.25
WestServices0.75
Use your own file

Drop one file anywhere on this page. It is read in your browser; no file is uploaded.

Nothing is uploaded.

Read locallyThe original file stays in the browser.

Share deliberatelyMCP shares supported metadata and requested results with the chat host.

Separate actionsOnline saves and support uploads require their own actions.

How does this workflow work?

What is the direct answer to this workbook question?

To explain a complex Tableau Level of Detail expression with an AI agent, supply both the curly-brace formula ({ FIXED | INCLUDE | EXCLUDE [Dims] : AGG([Measure]) }) and the worksheet's active shelf dimensions and filters. Without the worksheet grain, an agent cannot explain INCLUDE or EXCLUDE accurately. Run LODs in the xmetric formula playground.

Why does a pasted LOD formula need its surrounding context?

If you paste { EXCLUDE [Category] : SUM([Sales]) } into a chat prompt by itself, the agent knows you are excluding Category, but it has no idea what dimensions remain on the worksheet.

In Tableau's calculation grammar (and in xmetric), every Level of Detail expression interacts with two external contexts:

  1. The View Level of Detail (the pills on Rows, Columns, Color, Detail): INCLUDE adds dimensions to the view grain; EXCLUDE subtracts dimensions from the view grain; FIXED ignores the view grain and groups only by the dimensions listed before the colon.
  2. The Filter Shelf: Context filters apply before FIXED LODs, while regular Dimension filters apply after FIXED LODs but before INCLUDE and EXCLUDE LODs.

How can I break down a nested LOD expression?

When you encounter a deeply nested formula in a legacy .twbx workbook, read it from the innermost curly braces { ... } outward:

// Example nested LOD from a customer retention workbook
AVG({ INCLUDE [Customer ID] : SUM(
  IF [Order Date] > { FIXED [Customer ID] : MIN([Order Date]) }
  THEN [Sales]
  ELSE 0
  END
) })

What does the inner FIXED block calculate?

Compute the first Order Date at Customer ID grain before applying the surrounding row comparison.

  • Formula: { FIXED [Customer ID] : MIN([Order Date]) }
  • Plain English: Find each customer's very first order date across the entire dataset (ignoring standard dimension filters on the sheet).
  • Row comparison: IF [Order Date] > [First Order Date] THEN [Sales] ELSE 0 END keeps only repeat-purchase revenue after the customer's first order date.

What does the middle INCLUDE block calculate?

Add Customer ID to the view grain and sum the selected repeat-purchase revenue at that finer grain.

  • Formula: { INCLUDE [Customer ID] : SUM(...) }
  • Plain English: For whatever dimension is on the chart (for example, Region on Rows), first sum repeat-purchase revenue per individual Customer ID inside that region.

What does the outer AVG wrapper calculate?

Average the per-customer totals at the final chart grain.

  • Formula: AVG(...)
  • Plain English: Average those per-customer repeat-revenue totals across all customers in each Region.

What SQL expresses the example LOD grain?

Translating that 6-line nested LOD into DuckDB or Postgres SQL produces two clean CTEs that any engineer or coding agent can verify:

WITH customer_first_order AS (
  -- Step 1: FIXED [Customer ID] : MIN([Order Date])
  SELECT
    customer_id,
    MIN(order_date) AS first_order_date
  FROM orders
  GROUP BY customer_id
),
customer_repeat_spend_by_region AS (
  -- Step 2: INCLUDE [Customer ID] : SUM(repeat sales) within each Region (view grain)
  SELECT
    o.region,
    o.customer_id,
    SUM(
      CASE
        WHEN o.order_date > c.first_order_date THEN o.sales
        ELSE 0
      END
    ) AS repeat_sales_per_customer
  FROM orders o
  JOIN customer_first_order c
    ON o.customer_id = c.customer_id
  GROUP BY o.region, o.customer_id
)
-- Step 3: Outer AVG() at the worksheet's Region grain
SELECT
  region,
  AVG(repeat_sales_per_customer) AS avg_repeat_spend_per_customer
FROM customer_repeat_spend_by_region
GROUP BY region;

How can I ask an agent to explain the formula accurately?

Whenever you ask an AI assistant to explain or translate a workbook formula, pass these four fields:

Explain this Tableau LOD calculation and write the exact DuckDB SQL:
1. Formula: <paste formula, resolving any inner calculated fields>
2. Dimensions on the worksheet (Rows/Columns/Color/Detail): <list pills>
3. Context filters on the worksheet: <list grey context filter pills>
4. Regular dimension filters on the worksheet: <list blue dimension filter pills>

Or drop the .twbx or .twb into the xmetric workbook inspector (/inspect/) to list its sheets, data sources, and calculated fields, and run the LOD formula in the formula playground (/play/) to see its result on sample data and its SQL, for free. To see the formula in its real view grain, open the workbook in the xmetric app (/app/) and change the pills on Rows, Columns and Filters.

What does `{ : SUM([Sales]) }` without the word FIXED mean?

A curly-brace expression with no keyword and no dimension list ({ SUM([Sales]) }) is shorthand for { FIXED : SUM([Sales]) }. It computes the grand total across the entire table (after Context Filters) and repeats that scalar value on every row.

Why does Tableau require an aggregation in front of an LOD on a shelf?

An INCLUDE or EXCLUDE LOD always produces a measure that must be aggregated to the view grain (such as SUM or AVG). A FIXED LOD can be used either as a row-level value/dimension (when fixed at or finer than the data grain) or aggregated when placed on a measure shelf.

Can I test my own LOD formulas on a CSV in xmetric?

Yes. Open your CSV, Excel or Parquet file (or a .twbx) in the xmetric app, add the LOD as a calculated field, and place it on shelves to see how it behaves at your view grain. You can also run FIXED, INCLUDE, and EXCLUDE expressions on sample data in the formula playground. All of it is free, and your file stays in the browser unless you save online.

Run your LOD in the formula playground, then build the full view in the xmetric app.

What data does this worked example use?

The initial view uses authored synthetic data, not customer data or a captured agent session.

The example record lists its file, calculation or SQL and expected values. The live browser result is computed by xmetric’s existing engine or workbook inspector. Samples are excluded from own-data activation reporting.