Akmal Kuliev
10/29/2025, 2:00 AMYvonne Changamuka
10/29/2025, 8:31 AMSUM(), AVG(), COUNT(), etc., around your fact or calculation.
• For example, instead of {fact/your_fact}, use SUM({fact/your_fact}) or another appropriate aggregation.
If this doesn't help, kindly share a direct link to the report with the failing metric to allow us investigate and provide further assistance.Akmal Kuliev
10/29/2025, 1:32 PMAkmal Kuliev
10/29/2025, 1:34 PMSELECT IF DATETIME_DIFF({label/cleared_date.day},{label/posted_date.day} ) <=3
THEN
(SELECT IFNULL(SELECT COUNT({label/claim_id})
where {label/autopost_statuses_table.autopost_status} IN("Posted", "Pre Posted" ) ,0))
/
(SELECT COUNT({label/claim_id}))
ELSE NULL
ENDYvonne Changamuka
10/29/2025, 3:09 PMDATETIME_DIFF function is not an aggregation function. When you use it in a metric that is sliced by attributes (like claim_id), you must specify the dataset context using the BY keyword. For example:
SELECT DATETIME_DIFF({label/cleared_date.day}, {label/posted_date.day}) BY {dataset/your_dataset}
Without the BY clause, GoodData does not know how to aggregate the difference for each row, which can cause errors, more information on this in DATETIME_DIFF documentation.
2. IF/CASE and Aggregation
In MAQL, conditional statements like IF or CASE should be wrapped inside an aggregation function (such as SUM or AVG) when used in a metric that is sliced by attributes. This ensures the metric is computed at the correct dimensionality CASE documentation.
3. Nesting SELECT Statements
You are nesting SELECT statements inside your IF condition, which is not the recommended MAQL pattern. Instead, you should use aggregations directly and avoid unnecessary nested SELECT statements.
4. COUNT and IFNULL
The use of IFNULL is correct for handling nulls, but it should be applied to the result of an aggregation, not to a nested SELECT.
How to Fix
You should rewrite your metric to:
• Use DATETIME_DIFF with the BY clause.
• Wrap the IF statement inside an aggregation (e.g., SUM or AVG).not nested selects
IF syntax SELECT IF ( <condition> , <then_expression> , <else_expression> )
• Avoid unnecessary nested SELECT statements.
or equivalently:
SELECT CASE WHEN <condition> THEN <then_expression> ELSE <else_expression> END
You cannot write SELECT IF <condition> THEN ... ELSE ... END.
Example Rewrite of how you can express what you intended (ratio of certain claims if dates are within 3 days)
SELECT
IF (
DATETIME_DIFF({label/cleared_date.day}, {label/posted_date.day}) <= 3,
(SELECT COUNT({label/claim_id})
WHERE {label/autopost_statuses_table.autopost_status} IN ("Posted", "Pre Posted"))
/
(SELECT COUNT({label/claim_id})),
NULL
)
Let me know if this helps. If not, kindly share a direct link to the report, feel free to share via dm. ThanksAkmal Kuliev
10/30/2025, 2:23 AM