Hello - I am working with some messy data that needs to be adjusted in certain cases, but don’t have access to the upstream database. The gist of the problem is I need a new field that is based off of the minimum between 2 dates in other existing columns. Have tried the following approaches:
dimension: adjusted_date {
type: date
sql: CASE WHEN ${field1} > ${field2} THEN ${field2}
ELSE ${field1}
END ;;
}
dimension: adjusted_date {
type: date
sql: min(${field1},${field2}) ;;
}
Both approaches pass LookML validation, but neither works in Looker charts or filters. I receive errors that look like the following:
The Snowflake database encountered an error while running this query.
SQL compilation error: error line 9 at position 1,604 too many arguments for function [MIN(TO_CHAR(field1, 'YYYY-MM-DD'), TO_CHAR(field2, 'YYYY-MM-DD'))] expected 1, got 2