Cathy Liu
08/25/2026, 1:53 AMkapa.ai
08/25/2026, 1:53 AMCASE 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`:
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.Yvonne Changamuka
08/25/2026, 9:52 AM