Hi I am looking for some support. I have a visual ...
# gooddata-cloud
c
Hi I am looking for some support. I have a visual that is dividing a number of jobs where a column = 1 against the total number of jobs but when the column has no entries I am getting no data. Is there a way to ensure it returns a 0 instead
k
This is a classic null value handling issue in GoodData. When the filtered metric (jobs where column = 1) finds no matching rows, it returns
NULL
instead of
0
, which causes the entire division to return
NULL
(and display as "no data"). The solution is to wrap your numerator metric in an
IFNULL
clause so that missing values are treated as
0
rather than
NULL
. Your metric definition should look something like this:
Copy code
SELECT     IFNULL(         (SELECT COUNT({attribute/job_id}) WHERE {attribute/your_column} = 1),         0     )     /     (SELECT COUNT({attribute/job_id}))
This ensures that when there are no jobs where the column equals 1, the numerator returns
0
instead of
NULL
, and the division can still be performed. [IFNULL docs] A few things to keep in mind: • IFNULL does not create missing rows — it only substitutes a value when a row exists but the metric returns null. If there are no rows at all for a given attribute value, IFNULL alone won't make them appear. [IFNULL docs] • Use IFNULL selectively — the documentation notes it can add computing time, so apply it only where null values are causing issues, not across all metrics. [IFNULL docs] • Division by zero — if the total job count could also be zero in some contexts, you may also want to handle that case to avoid errors. If after applying
IFNULL
you're still seeing "no data", it's likely that the rows themselves don't exist in your dataset for that context, which would require a different approach (such as loading placeholder data or revisiting your LDM). 👍 0 button 👎 0 button ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups. 👀 Our Support team monitors all messages and will jump in if needed.