It’s not uncommon to want to display ‘0’ instead of NULL. Does anyone have any good techniques for handling this?
I usually suggest using SQL’s COALESCE() function to swap a NULL out with a zero, but I’m wondering if people have any better ideas.
Here’s what I do:
- measure: cancelled_count
type: count
drill_fields: detail
filters:
cancelled: Yes
- measure: not_cancelled_count
type: count
drill_fields: detail*
filters:
cancelled: No
- measure: percent_cancelled
type: number
decimals: 2
sql: 100.0 * COALESCE(${cancelled_count}/${count}, 0)
Yeah, I know that’s not a great example. I bet you have better ones!