Access to date dimensions from SQL:

tumikosha
Participant II

Why I can access to number or string fields, but not to Date fields?

view: test2 {
derived_table: {
sql:
WITH EX AS (
SELECT 1 as ID, 1 as age, 'Oleg' as name, PARSE_DATE("%Y-%m-%d", "2021-01-01") as dt
) SELECT * FROM EX ;;
}
dimension: name {
sql: ${TABLE}.name ;;
}
dimension: dt {
type: date
sql: ${TABLE}.dt ;;
}

measure: sum_by_name {
label: "SUM by name "
type: number
sql: (
select sum(age) from test2 as X
where TRUE
{% if test2Explore.name._in_query %} and X.name=${TABLE}.name {% endif %} -- OK
{% if test2Explore.gender._in_query %} and X.gender=${TABLE}.gender {% endif %} --OK
{% if test2Explore.dt._in_query %} and X.dt= ${TABLE}.dt {% endif %} -- ERROR
-- Query execution failed: - WHERE clause expression references
-- test2Explore.dt which is neither grouped nor aggregated at [33:39]
) ;;
}


 

488ac7ac-0658-4ef8-ad95-795450d7318b.png
0 0 41
0 REPLIES 0
Top Labels in this Space
Top Solution Authors