I need to make a calculated field for when the date is greater than 6/27/23 then use one calculation else use a different one: My calculated field is as follows:
ifelse({ga_date} >= '2023-06-27', 1 - (sum(engagedsessions)/sum(sessions)), sum(bounces)/sum(sessions))
but I am getting the error :
Mismatched aggregation. Custom aggregations can’t contain both aggregate “SUM” and non-aggregated fields “SUM(“engagedsessions”)”, in any combination. Any help is appreciated
Try if below calculation works,
ifelse({ga_date} >= ‘2023-06-27’, Max(1) - (sum(engagedsessions)/sum(sessions)), sum(bounces)/sum(sessions))
Hi @so2605 , @Vignesh_Kannan ,
The issue with the ifelse calc is that the condition used is a non aggregate.
Wrapping the date in a max will work if your intent is to display results at day grain.
ifelse(max({ga_date}) >= '2023-06-27', 1 - (sum(engagedsessions)/sum(sessions)), sum(bounces)/sum(sessions))
To explain this further, let’s take a simple example.
CalcTest
ifelse(max({Order Date})>='2023-06-27', 1-sum(Profit), sum(Sales) )
When used at day grain, the above calc will give you 1-sum(profit) for all days later than 2023-06-27 and sum(Sales) for that date and older.
When used at year grain, it will give you 1-sum(profit) for entire 2023 as max(Order date) from 2023 is currently greater than 2023-06-27.
I’m marking this as solution to this question for now. Let us know if you have further questions.
Regards,
Arun Santhosh
