I am trying to translate this SQL into a calculated field

```
select year, month, sum(amortized_cost) as cost,
sum(amortized_cost) /
(case
when month = '2' then 28
when month = '4' then 30
when month = '6' then 30
when month = '9' then 30
when month = '11' then 30
else 31
end) * 30 as normalised_cost
from tmp_summary
group by year, month
```

This calculation succeeds

```
avgOver(sum({amortized_cost}),[{year},{month}]) / 30
```

but this one fails with a generic error

```
avgOver(sum({amortized_cost}),[{year},{month}]) / ifelse({month} = '2', 28,31)
```