Skip to main content

Filters & LOD

4. Filters โ€” Tableau's Processing Orderโ€‹

Filters are applied in a specific priority order. This is a frequent interview question.

Context Filter โ€” The Most Asked Interview Questionโ€‹

Problem: You want "Top 10 customers in Delhi." If you apply a normal Top 10 filter alongside a Delhi filter, Tableau finds Top 10 from ALL India first, THEN filters for Delhi โ€” giving wrong results.

Solution: Make the Delhi filter a Context Filter. Tableau will first isolate Delhi data, then find the Top 10 within that subset.

WITHOUT Context Filter:
Step 1: TOP 10 from ALL India โ†’ Maybe none from Delhi
Step 2: Filter Delhi โ†’ 0 results! โŒ

WITH Context Filter on City='Delhi':
Step 1: Filter Delhi first โ†’ All Delhi customers
Step 2: TOP 10 from Delhi โ†’ Correct 10 โœ…

๐Ÿง  Interview mein ek line: "Context filter creates a temporary table with the filtered data, and all subsequent filters work within that subset."


5. Calculated Fields & Table Calculationsโ€‹

5.1 Calculated Fieldsโ€‹

Custom formulas you create in Tableau. They are computed at the data source level.

Common Examples:

// Profit Margin
[Profit] / [Sales] * 100

// Customer Age Group
IF [Age] < 25 THEN 'Young'
ELSEIF [Age] < 40 THEN 'Middle'
ELSE 'Senior'
END

// Days Since Last Order
DATEDIFF('day', [Last_Order_Date], TODAY())

// Year-over-Year Growth
(SUM([Sales]) - LOOKUP(SUM([Sales]), -1)) / LOOKUP(SUM([Sales]), -1) * 100

5.2 Table Calculationsโ€‹

Computed after the main query based on what's visible in the view. They work on the result set, not the raw data.

CalculationWhat It DoesUse Case
Running TotalCumulative sum across rows"Total revenue accumulated over months"
Percent of TotalEach value as % of the sum"What % does each region contribute?"
DifferenceChange from previous value"How much did sales change month-to-month?"
Percent Difference% change from previous value"Monthly growth rate"
RankRank values"Rank products by revenue"
Moving AverageAverage of N surrounding values"3-month moving average to smooth trends"

๐Ÿง  Interview ke liye important: "Table calculations are computed on the result set, not the underlying data. That's why they depend on the Table (across) or Pane (down) direction โ€” called addressing and partitioning."

5.3 Sets and Groupsโ€‹

FeatureWhat It IsExample
GroupManually combine dimension membersGroup Delhi, Mumbai, Bangalore into "Metro"
SetDynamic or fixed subset based on conditionTop 20% customers by revenue (updates automatically)

6. LOD Expressions โ€” Level of Detailโ€‹

LOD expressions let you compute aggregations at a different granularity than what's shown in the visualization.

LOD TypeSyntaxBehavior
FIXED{FIXED [City] : SUM([Sales])}Always computes at the specified level, ignores the view
INCLUDE{INCLUDE [Customer] : AVG([Sales])}Adds the specified dimension to the view's granularity
EXCLUDE{EXCLUDE [Month] : SUM([Sales])}Removes the specified dimension from the view's granularity

Example โ€” FIXED LOD:โ€‹

Scenario: Your view shows product-level sales. You want each product row to also display its CATEGORY total for comparison.

Calculated Field: Category Total
{FIXED [Category] : SUM([Sales])}

Result:
Product: Laptop | Sales: 45000 | Category Total: 185000
Product: Monitor | Sales: 20000 | Category Total: 185000
Product: Mouse | Sales: 500 | Category Total: 185000
โ†‘ Same for all Tech products

Example โ€” INCLUDE LOD:โ€‹

Scenario: View shows City-level data. You want the average order value per customer per city (not the city-level average).

Calculated Field: Avg Order per Customer
{INCLUDE [Customer_ID] : AVG([Order_Amount])}

This first calculates AVG order for EACH customer,
then aggregates those customer-level averages up to the City view.
Without LOD, you'd just get the city's overall average โ€” which
treats a customer with 1 order and 100 orders equally.

๐Ÿง  Yaad kaise rakho: FIXED = "is level pe fix karo, view ko ignore karo." INCLUDE = "ek aur level add karo." EXCLUDE = "ek level hatao."


7. Dashboard Design Best Practicesโ€‹

RuleWhyExample
KPIs at the topFirst glance should show key numbersTotal Revenue, Growth %, Customer Count as big scorecards
Follow Z-patternUsers read leftโ†’right, topโ†’bottomImportant charts top-left, supporting charts bottom-right
Maximum 3-4 chartsInformation overload confuses stakeholdersRevenue trend + Category split + Top customers + KPI cards
Consistent colorsSame color = same meaning throughoutGreen = good, Red = bad, Blue = neutral
Interactive filtersLet users explore on their ownRegion, Date Range, Product Category dropdowns
Descriptive titles"Revenue" โŒ, "Monthly Revenue Trend (FY 2023-24)" โœ…Include metric name + time period
Mobile-friendlyExecutives check dashboards on phonesCreate device-specific layouts

Dashboard Actionsโ€‹

Action TypeWhat It DoesExample
FilterClicking a mark filters other sheetsClick a bar in City chart โ†’ filters Product chart
HighlightClicking a mark highlights related marksClick "Technology" โ†’ highlights in all charts
URLOpens a webpage on clickC