Mismatched aggregation on MAX formula

Hello! :slight_smile:
I m getting this message below for query descripted after

“Mismatched aggregation. Custom aggregations can’t contain both aggregate “MAX” and non-aggregated fields “MAX(“car_utilized”)”, in any combination”

{current_car_limit} - max({car_utilized})

both fields (current_car_limit and car_utilized) are number type

Can you please let me know a workaround? I basically need to subtract the MAX number from car_utilized from the total current_car_limit

thanks

Hi @Yohan_Trindade,

If you want to use the max value of car_utilized in the entire dataset, try this:
{current_car_limit} - maxOver({car_utilized}, , PRE_AGG)

1 Like

Thank you @David_Wong for sharing the solution :slight_smile: This worked perfectly and I verified as well.

Regards - Sanjeeb

Hey, @David_Wong , perhaps a noobie question, but I dont know how to use the proposed formula. Should it be like this (literally as it is written or should I substitute something?

{current_car_limit} - maxOver({car_utilized}, , PRE_AGG)

thanks
Y

Hi @Yohan_Trindade - Please find the formula below.

{current_car_limit} - maxOver({car_utilized},[], PRE_AGG)

Regards - Sanjeeb

You need to put something between the commas. If you put empty square brackets, it means calculate the max over the entire dataset.

1 Like