🎯 Mục tiêu bài học
Sau bài học này, bạn sẽ:
✅ Master LOD Expressions: Cohort, CLV, New vs Returning
✅ Analytics pane: Trend Line, Forecast, Clustering
✅ Tableau Prep basics cho data cleaning
✅ Performance optimization: Extracts, Context Filters
✅ Advanced: Set Actions, Dynamic Zone, Small Multiples
Thời gian: 45 phút | Độ khó: Advanced | Tool: Tableau Desktop
📖 Bảng Thuật Ngữ Quan Trọng
| Thuật ngữ | Tiếng Việt | Mô tả |
|---|---|---|
| Cohort Analysis | Phân tích đoàn hệ | Group customers by acquisition period |
| CLV | Giá trị vòng đời KH | Customer Lifetime Value |
| Trend Line | Đường xu hướng | Linear, polynomial, exponential fit |
| Forecast | Dự báo | Time-series prediction |
| Clustering | Phân cụm | K-means grouping tự động |
| Tableau Prep | Chuẩn bị dữ liệu | Visual ETL tool |
| Extract (.hyper) | Trích xuất | Local data cache cho performance |
| Context Filter | Bộ lọc ngữ cảnh | Filter ưu tiên, áp dụng trước |
| Set Action | Hành động tập hợp | User select → update set → calcs react |
| Small Multiples | Nhiều biểu đồ nhỏ | Same chart repeated per category |
Checkpoint
LOD = FIXED/INCLUDE/EXCLUDE. Cohort = group by acquisition. Extract (.hyper) = local cache. Context Filter = priority filter. Bạn nhớ 3 loại LOD chưa?
🎯 1. LOD Expressions Deep Dive
1.1 Cohort Analysis
1// Customer Acquisition Year2{ FIXED [Customer ID] : MIN(YEAR([Order Date])) }3 4// Use: Color by cohort year → see retention over time1.2 Customer Lifetime Value
1// Total revenue per customer2{ FIXED [Customer ID] : SUM([Sales]) }3 4// Order frequency5{ FIXED [Customer ID] : COUNTD([Order ID]) }6 7// First & Last order8{ FIXED [Customer ID] : MIN([Order Date]) }9{ FIXED [Customer ID] : MAX([Order Date]) }10 11// Active days12DATEDIFF('day',13 { FIXED [Customer ID] : MIN([Order Date]) },14 { FIXED [Customer ID] : MAX([Order Date]) }15)1.3 New vs Returning Customers
1IF [Order Date] = { FIXED [Customer ID] : MIN([Order Date]) }2THEN "New Customer"3ELSE "Returning Customer"4END1.4 Percent of Parent
1// Sub-category as % of category2SUM([Sales]) / { FIXED [Category] : SUM([Sales]) }3 4// Product as % of total5SUM([Sales]) / { FIXED : SUM([Sales]) }LOD Use Cases thực tế: Customer cohort analysis, CLV calculation, New vs Returning segmentation, % of parent. FIXED là powerful nhất — bỏ qua mọi viz filters!
Checkpoint
Cohort = FIXED Customer : MIN(YEAR(Date)). CLV = FIXED Customer : SUM(Sales). New vs Returning = compare Order Date với FIXED MIN. Mỗi LOD giải quyết 1 business question!
📊 2. Analytics Pane
2.1 Available Analytics
2.2 Trend Line
11. Analytics pane → Drag "Trend Line" onto chart22. Models: Linear, Logarithmic, Polynomial, Power33. Options: confidence bands, R-squared2.3 Forecast
11. Drag "Forecast" onto line chart22. Options:3 - Length: 3, 6, 12 months4 - Prediction interval: 90%, 95%5 - Seasonal pattern: Auto-detectBest for: Sales forecasting, demand planning.
2.4 Clustering
11. Drag "Cluster" onto scatter plot22. Number of clusters: Auto or custom (2-10)33. Result: points colored by clusterBest for: Customer segmentation, product grouping.
Forecast trong Tableau dùng exponential smoothing — tự detect seasonal patterns. Rất tốt cho quick prediction nhưng không thay thế proper ML models!
Checkpoint
Analytics Pane: Trend Line (regression), Forecast (time-series), Cluster (k-means). Drag-and-drop lên chart — không cần code! Forecast dùng exponential smoothing.
🔧 3. Tableau Prep
3.1 Why Tableau Prep?
| Before Prep | With Prep |
|---|---|
| Manual Excel cleanup | Visual data cleaning |
| SQL transformations | Drag-drop operations |
| Data lives in silos | Union/join multiple sources |
| Repetitive process | Saved & scheduled flows |
3.2 Key Operations
| Operation | Use Case |
|---|---|
| Clean | Rename, remove, change types |
| Filter | Remove rows (null, invalid) |
| Group | Merge similar values (typos) |
| Pivot | Wide → long format |
| Union | Combine same-structure tables |
| Join | Combine different tables on key |
| Aggregate | Group by + summarize |
| Script | Python/R for advanced transform |
3.3 Typical Prep Flow
1Input (Excel files)2 ↓3Clean: Fix column names, data types4 ↓5Filter: Remove nulls, test data6 ↓7Join: Customer table + Orders table8 ↓9Calculate: Add profit margin, segments10 ↓11Output: Tableau Extract (.hyper)Checkpoint
Tableau Prep = visual ETL tool. Flow: Input → Clean → Filter → Join → Calculate → Output (.hyper). Saved flows có thể schedule refresh tự động!
⚡ 4. Performance Optimization
5.1 Performance Recording
1Help → Settings → Start Performance Recording2→ Navigate dashboard → Stop Recording → View bottlenecks5.2 Optimization Tips
| Area | Tip |
|---|---|
| Data | Use Extracts (.hyper) instead of Live |
| Filters | Context filters first, then normal |
| Calculations | Row-level calcs faster than LOD in some cases |
| Dashboard | Max 6-8 sheets per dashboard |
| Dates | Discrete dates, not continuous |
| Marks | Reduce number (< 10K ideal) |
5.3 Extract Optimization
1Data Source → Extract:21. Add filters to reduce data size32. Aggregate to visible dimensions43. Hide unused fields54. Schedule incremental refreshPerformance killers: Live connections to slow databases, too many marks (>100K), complex LOD stacking, excessive filters. Always use Extracts cho production dashboards!
Checkpoint
Extracts > Live connections. Context Filters áp dụng trước normal filters. Max 6-8 sheets per dashboard. < 10K marks ideal. Performance Recording để debug!
🚀 5. Advanced Techniques
5.1 Set Actions
1Dashboard → Actions → Change Set Values2Set: [My Set]3Run on: Select4Clearing: Remove from setUse case: User selects items → set updates → calculations react.
5.2 Dynamic Zone Visibility
11. Create boolean calculated field22. Control container visibility based on field value3→ Dynamic dashboard layout!5.3 Small Multiples
11. Drag [Category] → Columns22. Drag [Month] → Columns (nested)33. Drag [Sales] → Rows4→ One chart per category, same scaleCheckpoint
Set Actions = interactive set membership. Dynamic Zone = show/hide containers based on logic. Small Multiples = same chart repeated per category — great for comparison!
📋 Tổng kết
Kiến thức đã học
| Chủ đề | Nội dung chính | Tầm quan trọng |
|---|---|---|
| LOD Deep Dive | Cohort, CLV, New/Returning, % Parent | Advanced analysis |
| Analytics | Trend, Forecast, Cluster (built-in) | Predictive |
| Tableau Prep | Visual ETL, flows, scheduling | Data prep |
| Performance | Extracts, Context Filters, mark limits | Production |
| Advanced | Set Actions, Dynamic Zone, Small Multiples | Premium features |
Câu hỏi tự kiểm tra
- LOD Expression giải quyết được bài toán gì mà Table Calcs không làm được?
- Tableau Prep khác Power Query thế nào?
- Context Filter giúp cải thiện performance thế nào?
- Set Actions dùng trong trường hợp nào?
Bài tiếp theo: DAX Fundamentals — Chuyển sang Power BI và học DAX!
🎉 Tuyệt vời! Bạn đã master Tableau nâng cao!
Nhớ: LOD + Analytics + Performance = Tableau Pro. Bạn đã sẵn sàng cho bất kỳ dự án Tableau nào!
