Hi Team, This metric was incorrect in GoodData. Co...
# gooddata-cloud
c
Hi Team, This metric was incorrect in GoodData. Could you let me know how I should update it correctly?
k
In GoodData MAQL, the expression in your screenshot has a few syntax and structural issues: 1. Inline aggregation inside
CASE
conditions:
Functions like
MIN(...)
cannot be called directly inside a
CASE WHEN
clause without proper nesting or selection [CASE Syntax]. 2. Attribute comparisons require string literals: Comparing date or label attributes requires quotes around the literal value (e.g.,
"2023"
instead of
2023
) [Filtering with WHERE]. 3. Dataset context for non-numeric/date `MIN`: When finding the
MIN
of an attribute/label, you must specify the dataset or primary key context [MIN Aggregation]. Recommended Solutions Depending on what you want to achieve, you can structure the metric in one of the following ways: Option 1: Using GREATEST (Simpler and Cleaner) If your goal is to return either the minimum financial year or
2023
(whichever is larger, effectively capping the lower bound at 2023), use `GREATEST`:
Copy code
SELECT GREATEST(
  (SELECT MIN({label/DTM_LGA_HALF_YEARLY_EXPENDITURE.FINANCIAL_YEAR}, {dataset/DTM_LGA_HALF_YEARLY_EXPENDITURE})),
  2023
)
Option 2: Pre-calculating the Minimum Year in a Metric To keep your
CASE
logic clean and avoid multidimensionality/syntax errors: 1. Create a separate metric for the minimum year (e.g.,
metric/min_financial_year
):SELECT MIN({label/DTM_LGA_HALF_YEARLY_EXPENDITURE.FINANCIAL_YEAR}, {dataset/DTM_LGA_HALF_YEARLY_EXPENDITURE}) 2. Reference it inside your
CASE
metric
:SELECT CASE WHEN {metric/min_financial_year} < 2023 THEN 2023 ELSE {metric/min_financial_year} END _(Note: Replace
{dataset/DTM_LGA_HALF_YEARLY_EXPENDITURE}
with the exact dataset identifier in your workspace [MIN Aggregation]. If you need this evaluated at the
{label/CURRENT_VGCCC_NAME}
level, add
BY {label/CURRENT_VGCCC_NAME}
to the inner
MIN
metric)._ 👍 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.
y
Hello Cathy, Our AI assistant provided and accurate response. Please let us know if this helps or if you have any further questions.