Mismatched aggregation error with ifelse() and LAC-A when trying to calculate sum for prior year

Hi, I’m trying to create a simple calculation that gives me the sum of impressions grouped by month for the prior year using an ifelse() and a LAC-A calculation but I keep getting a mismatched aggregation error. Note that the year column I’m using here is formatted as a string. So far I have:

ifelse(
{year} = toString(extract("YYYY", now())-1),
sum({impressions}, [{month}]),
NULL
)

Can someone tell me why this is giving a mismatched aggregation error?

Thank you!

Hi @azhukova,

You have to move your ifelse inside the sum. Take a look at the mismatched aggregation section at the bottom of this article:

1 Like

Thanks so much David! This helped a ton