how to pass a hardcoded date to a custom dimension?

i am trying to set a custom dimension based on certain dates using case when. For example-

case (when (date=”2022-09-02”, “sale day”), null)

this should add a column to my view along with the date column which identifies the promos on given dates.

Date Promo
2022-09-02 Sale Day
2022-09-03 Null

but i am not able to pass the value “2022-09-02” in the custom dimension it throws an errors saying cant compare date with string.

Arguments types for `>=` must all match. Types given: (Date, String)

I tried to_date function to convert my date to the correct format but that didn't work either.

Invalid function for sql context: "to_date"

what is the best way to achieve this? i don't want to use a table calculation because i want to add this column as a filter as well. is this not possible using custom dimensions? do i need to use lookml?

Solved Solved
0 2 1,692
1 ACCEPTED SOLUTION

Just try date(2022,9,2) this will build a static date with the correct type

View solution in original post

2 REPLIES 2

Just try date(2022,9,2) this will build a static date with the correct type

worked perfectly thank u!

Top Labels in this Space