Issue with creating custom columns with aggregate values

Hi, apologies if this has already been recorded, but I couldn't find it when I looked.

I am using 0.33, but I'm fairly sure a similar thing was happening earlier. I have tested a version of the same query in the native SQL editor (which worked), but I was forced to to that because the GUI editor wouldn't let me do it.

Basically, I want to have a custom column that subtracts one aggregated column value from another in the same table. When I go to add the custom column, the only field values that are available to me is a single value called 'avg' (both aggregate columns are averages).

I was playing with this and if I changed one of the columns to a sum aggregation, it appeared as a field in the list, and I could do the calculation with no issues.

What appears to be happening is that metabase is giving the averages a generic name ('avg'), and doesn't handle it when there are more than one of the same type:

Thanks.

Hi @mattblanc
Go and upvote this issue - and the two linked issues too - by clicking the :+1: on the first post:
https://github.com/metabase/metabase/issues/10759

I did it by just creating a 3rd summary field:


Must admit, I didn't think SQL would do the calculation correctly, but it looks fine.