Best practices for using isBlank, isDefined, ifBlank, and ifDefined
Using the right functions has a real impact on model performance, sparsity, and database computation efficiency.
Here’s a practical breakdown to help you decide the best formula for your use case — based on recent technical discussions with Pigment Engineers.
🚀 TL;DR
| Recommendation | Why? |
| Use isDefined instead of isBlank | To avoid densifying your metrics unnecessarily. |
| Use ifBlank instead of ifDefined (when the second metric is sparse) | Preserves sparsity and optimizes database computation. |
| Use ifBlank instead of if(isBlank(A), B, A) | Cleaner formulas and simpler database computation. |
| No impact when choosing between ifDefined and if(isDefined()) | They behave exactly the same for computation. |
🔍 Key Concepts and Recommendations
ifBlank(A,B)
- Behavior: Acts like A if A is defined, otherwise returns B.
- Performance: Efficient; avoids densification unless B is dense.
- Best Practice:
✅ Prefer ifBlank over if(isBlank(A), B, A) for clarity and efficiency. - Important note: as it looks very similar to isBlank and isNotBlank it is important to make clear that this function will not densify (unless metric B is dense).
isBlank and isNotBlank
- Behavior: Always outputs True or False, resulting in a dense metric.
- Impact: Densification can negatively affect model performance.
- Best Practice: ⚠️ Use cautiously, only use when you need False as an outcome.
isDefined
- Behavior: Outputs True if defined, otherwise Blank.
- Impact: Preserves sparsity, keeping models lighter and faster.
- Best Practice: ✅ Favor isDefined over isBlank for better sparsity management.
ifDefined
- Behavior: Shortcut equivalent to if(isDefined(...)).
- Impact: No impact on database computation; purely a formula-writing shortcut.
- Best Practice: ✍️ Use for cleaner model formulas when checking for defined values.
Why was isNotDefined not created?
- Introducing isNotDefined led to ambiguous cases mixing False and Blank.
- Workaround:
Use if(isDefined(X), blank, true) if you need this behavior.
🎯 Final Thoughts
Even small formula decisions — like choosing ifBlank instead of if(isBlank()) — can make a big difference at scale.
By keeping models sparse and simple, we can build faster, cleaner, and more maintainable models.

