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.
| Calculation | What It Does | Use Case |
|---|---|---|
| Running Total | Cumulative sum across rows | "Total revenue accumulated over months" |
| Percent of Total | Each value as % of the sum | "What % does each region contribute?" |
| Difference | Change from previous value | "How much did sales change month-to-month?" |
| Percent Difference | % change from previous value | "Monthly growth rate" |
| Rank | Rank values | "Rank products by revenue" |
| Moving Average | Average 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โ
| Feature | What It Is | Example |
|---|---|---|
| Group | Manually combine dimension members | Group Delhi, Mumbai, Bangalore into "Metro" |
| Set | Dynamic or fixed subset based on condition | Top 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 Type | Syntax | Behavior |
|---|---|---|
| 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โ
| Rule | Why | Example |
|---|---|---|
| KPIs at the top | First glance should show key numbers | Total Revenue, Growth %, Customer Count as big scorecards |
| Follow Z-pattern | Users read leftโright, topโbottom | Important charts top-left, supporting charts bottom-right |
| Maximum 3-4 charts | Information overload confuses stakeholders | Revenue trend + Category split + Top customers + KPI cards |
| Consistent colors | Same color = same meaning throughout | Green = good, Red = bad, Blue = neutral |
| Interactive filters | Let users explore on their own | Region, Date Range, Product Category dropdowns |
| Descriptive titles | "Revenue" โ, "Monthly Revenue Trend (FY 2023-24)" โ | Include metric name + time period |
| Mobile-friendly | Executives check dashboards on phones | Create device-specific layouts |
Dashboard Actionsโ
| Action Type | What It Does | Example |
|---|---|---|
| Filter | Clicking a mark filters other sheets | Click a bar in City chart โ filters Product chart |
| Highlight | Clicking a mark highlights related marks | Click "Technology" โ highlights in all charts |
| URL | Opens a webpage on click | C |