Summary
In simple cases when an attribute function is used over another aggregate function, it works fine. But when the same aggregate is put inside a case when statement, the calculation shows a syntax error
Content
Hello,
I am working on a dataset as follows :

When I use aggregate function inside an attribute function, it works fine. but when the aggregate is put inside a case when statement as follows, or even the aggregate is multiplied, added, subtracted or divided by a number, a syntax error is shown, though the functional output is the same :

Another issue is that while creating a calculation in data visualization, when I use nested attribute functions, (an attribute over another attribute function) the calculation works fine. But when I apply it to the visualization, it shows a general error.
The sample calculation that is validated :

This is the error that I am getting :

Any solutions regarding the problems?