mirror of
https://github.com/forcedotcom/afv-library.git
synced 2026-08-09 00:42:46 +08:00
Adds a skill for authoring Tableau Next semantic models (SDMs) on Data 360: build from scratch, add data objects, define joins, enrich with calculated fields and metrics, and make models AI-ready. Smoke-tested against a live Data 360 org: SDM discovery, AI-readiness flip, dimension creation, metric creation, and description backfill all exercised end-to-end.
44 lines
1.6 KiB
Markdown
44 lines
1.6 KiB
Markdown
# Calculated Field Patterns
|
|
|
|
Aggregation types + common expression patterns for creating `_clc` measurements and dimensions. Companion to the create-a-calc-field workflow in [SKILL.md](../SKILL.md#calculated-fields).
|
|
|
|
## Aggregation Types
|
|
|
|
When creating measurements, choose the correct aggregation type based on how the field should behave in visualizations:
|
|
|
|
| Aggregation | Use When | Example |
|
|
|-------------|----------|---------|
|
|
| `Sum` | Additive values (revenue, count) | `SUM([Table].[Amount])` |
|
|
| `Avg` | Average needed (rates, percentages when raw values available) | `AVG([Table].[Close_Days])` |
|
|
| `UserAgg` | Expression already includes aggregation | `SUM([Table].[Won]) / SUM([Table].[Total])` |
|
|
| `Min` | Minimum value | `MIN([Table].[Close_Date])` |
|
|
| `Max` | Maximum value | `MAX([Table].[Amount])` |
|
|
| `Count` | Row count | `COUNT([Table].[Opportunity_Id])` |
|
|
|
|
**Critical:** Don't guess aggregation types. If uncertain, inspect the SDM first to see how similar fields are configured, or use `UserAgg` when your expression already includes aggregation functions.
|
|
|
|
## Common Expression Patterns
|
|
|
|
**Time calculations:**
|
|
```tableau
|
|
DATEDIFF('day', [Table].[Created_Date], [Table].[Close_Date])
|
|
```
|
|
|
|
**Conditional aggregation:**
|
|
```tableau
|
|
SUM(IF [Table].[Stage] = 'Closed Won' THEN [Table].[Amount] ELSE 0 END)
|
|
```
|
|
|
|
**String manipulation:**
|
|
```tableau
|
|
UPPER([Table].[Account_Name])
|
|
LEFT([Table].[Opportunity_Name], 10)
|
|
```
|
|
|
|
**Null handling:**
|
|
```tableau
|
|
IFNULL([Table].[Amount], 0)
|
|
```
|
|
|
|
See [tableau-functions.md](tableau-functions.md) for complete function reference and [patterns.md](patterns.md) for production-derived ratio / LOD / dimension patterns.
|