top of page

Welcome
to NumpyNinja Blogs

NumpyNinja: Blogs. Demystifying Tech,

One Blog at a Time.
Millions of views. 

Demystifying LOD Expressions

Tableau is a powerful and popular business intelligence tool focused on data visualization and analysis. It allows users to easily explore and understand data by creating interactive dashboards, charts, and graphs. Tableau's drag-and-drop interface and user-friendly design make it accessible to both technical and non-technical users, enabling them to discover insights and make data-driven decisions. 

ree

Aggregation And Granularity

Aggregation is the process by which Tableau summarizes data by combining multiple rows into a single value. In Tableau, we can aggregate measures or dimensions, though it is more common to aggregate measures.

Whenever a measure is added to a view, an aggregation is applied to that measure by default. The type of aggregation applied varies depending on the context of the view. Sum, average, and median are common aggregations for measures. ’Dimensions’ can also be aggregated to Minimum, Maximum, Count, and Count Discrete.


Granularity refers to the level of detail or how “fine” your data view is.

  • High granularity means very detailed data — for example, individual transactions or patients.

  • Low granularity means more summarized data — like totals per month, or averages per hospital.

In Tableau, granularity is controlled by the dimensions you include in your view:

  • More dimensions = finer granularity (more detail)

  • Fewer dimensions = coarser granularity (more summary)


Level Of Detail(LOD) Expressions

When you first start using Tableau, it’s easy to get hooked on how quickly you can spin up charts, dashboards, and uncover insights. But as you dig deeper, you eventually hit a snag—especially when your numbers aren’t lining up the way you expect.

Maybe you’re trying to find the average sales per customer, but your view is at the region level. Or perhaps you need a benchmark KPI that stays constant no matter how the dashboard is filtered.

That’s where Level of Detail (LOD) Expressions come in. They’re a powerful tool for controlling exactly how Tableau calculates your numbers—but many users avoid them because they seem tricky at first.

In this post, we’ll strip away the confusion. We’ll cover what LODs are, walk through the three types, and explore practical examples showing why every Tableau user should have them in their toolkit. By the end, you’ll know when and how to use FIXED, INCLUDE, and EXCLUDE—and how they can take your analysis to the next level.


Syntax of the LOD expressions :

Irrespective of the type of LOD used, the syntax is the same as below:

{ TYPE of LOD [Optional Dimension List]: AGGREGATE}


I used the Hospital Analytics dataset from the Maven Analytics website to demonstrate each type of LOD expression.

You’ll find a link to the dataset in the References section at the end of this blog, so you can practice along. The dataset includes five tables: Patients, Encounters, Payers, Procedures, and Organizations.


In Tableau, connect to the data source and create relationships between the five tables in the Relationships canvas as illustrated below.

ree

Now, let's explore the 3 types of LODs, one by one.


FIXED Level of Detail Expressions

  • Fixed LOD expressions calculate a value at a specific level of detail you define.

  • The calculation remains constant regardless of the dimensions or filters in the current view.


To display patient encounters, procedures, and their total claim costs, drag ID from the Patients table, Encounter Type (Description) from the Encounters table, and Procedure (Description) from the Procedures table onto Rows.

Next, drag Total Claim Cost from the Encounters table to the Text shelf on the Marks card.

You’ll now have a text table showing Patient ID, Encounter Type, Procedure, and the Total Claim Cost for each patient by encounter type and procedure performed.

ree

Now, I want to show the total cost for each patient, regardless of the level of detail in the view.


Solution: FIXED LOD Expression

To achieve this, we’ll create a calculated field using a FIXED LOD expression:

  1. In the Data pane, click the drop-down arrow next to the search bar.

  2. Select Create Calculated Field.

  3. Name the field Total Cost Per Patient.

  4. Enter the following formula:

{ FIXED [Patient]: SUM([Total Claim Cost]) }

  1. Click OK.


This new calculated field will appear under Measures in the Encounters table.

To display it in the visualization, simply double-click the calculated field.


ree

Result:

This results in the view below, where the total cost remains the same across different procedures for each patient. That’s because the calculation is fixed at the patient level, so the total cost doesn’t change based on procedure/Encounter Type.


INCLUDE Level of Detail Expressions

  • Include LOD expressions, and add specified dimensions to the view’s existing level of detail for the calculation.

  • This allows the calculation to be more detailed than the current view by temporarily including extra dimensions.


We want to find the average total claim cost per patient visit inside each hospital. But your view is currently showing data only at the hospital level (no patient details).


Solution: INCLUDE LOD Expression

INCLUDE lets us temporarily add the patient to the granularity for calculation.

Create a new Calculated field named Avg Visit Cost per Patient as below

{ INCLUDE [PatientID] : SUM([Total Claim Cost]) }

In your worksheet:

  • Drag Organization (Hospital) from encounters to Rows

  • Drag Name from payers to rows

  • Drag the Avg Visit Cost per Patient calculated field to Text

  • Set the aggregation of the calculated field to AVG (right-click the pill → Measure → Average)

ree

Result:

You’ll see the average total claim cost per patient for each hospital — even though the view itself only shows hospital-level data. The INCLUDE LOD temporarily adds patient granularity for the calculation, but keeps the visualization clean and aggregated at the hospital level.


EXCLUDE Level of Detail Expressions

  • Exclude LOD expressions, and remove specified dimensions from the view’s level of detail for the calculation.

  • This allows the calculation to be less detailed than the current view by ignoring certain dimensions.


You want to show the average total claim cost per hospital, but your view is currently more detailed — for example, showing costs by hospital and procedure.

If you use a regular aggregation like AVG([Total Claim Cost]), Tableau will calculate the average at the hospital–procedure level, which is more granular than you want.


Solution: EXCLUDE LOD Expression

EXCLUDE lets us temporarily remove a dimension (such as procedure) from the granularity for calculation.

Create a calculated field called Avg Cost per Hospital:

{ EXCLUDE [Procedure] : AVG([Total Claim Cost]) }

In your worksheet:

  • Drag Organization (Hospital) from encounters to Rows

  • Drag Procedure from procedures to Rows

  • Drag the Avg Cost per Hospital calculated field to Text

ree

Result:

You’ll see the same average cost per hospital repeated for each procedure in that hospital, because the calculation ignores the procedure dimension.


Conclusion

With LOD expressions, you can fine-tune the granularity of your view—making it more or less detailed as needed. They’re incredibly versatile, helping you handle duplicates, isolate certain records, create single aggregate values, or even turn rows into measures. Depending on the detail you want in your analysis, you can use any of the three LOD types in a variety of ways.

Thanks for reading!

 
 

+1 (302) 200-8320

NumPy_Ninja_Logo (1).png

Numpy Ninja Inc. 8 The Grn Ste A Dover, DE 19901

© Copyright 2025 by Numpy Ninja Inc.

  • Twitter
  • LinkedIn
bottom of page