Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have the following data and expression :
test:
LOAD *
inline
[year,code,X
2020,'A',10
2021,'A',7
2019,'C',25
2020,'C',50
];
sum(
Aggr(
sum({<year={$(=max(year))}>}
X
)
,code
)
)
I want the sum of X for the max year grouped by code.
For example here I want 7 + 50 = 57.
Unfortunately my expression gives me 7
How can I tell the variable $ to take the aggr group into account ?
Thanks you,
try with
sum(aggr(if(max(TOTAL <code> year)=year, sum(X)), code, year))
try with
sum(aggr(if(max(TOTAL <code> year)=year, sum(X)), code, year))
Nice, it works perfectly,
Thanks