why do i get an error when i fill in the formula in google data studio?

Viewed 27

I want to make a calculation column that contains sales targets for each month. i get error while filling formula in google data studio.

i get error = invalid formula - Operator ">=" doesn't support DATE >= TEXT. The operator ">=" supports ANY >= ANY.

case
    when Order Date>= '2014-01-01' and Order Date<'2015-01-01' then 30000
    when Order Date>= '2015-01-01' and Order Date<'2016-01-01' then 40000    
    else 50000
end

what should be the formula?thank you

1 Answers

invalid formula - Operator ">=" doesn't support DATE >= TEXT.

You may try below expresson.

case
    when Order Date>= DATE '2014-01-01' and Order Date< DATE '2015-01-01' then 30000
    when Order Date>= DATE '2015-01-01' and Order Date< DATE '2016-01-01' then 40000    
    else 50000
end

From Data Studio Help:

Date literals

To use literal date and time values in a calculated field, you can precede the value with the appropriate marker:

+---------+-----------------------+-----------------+
| Literal | Canonical date format |  Sample usage   |
+---------+-----------------------+-----------------+
| Date    | YYYY-[M]M-[D]D        | DATE '2021-4-1' |
+---------+-----------------------+-----------------+
Related