# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
New Contributor III

## Summation of Max values in a column

Hi all,

I have a problem with the summation of max values in a column. As you see below, my table has different master spendings and their subbranches. I want to sum the master spendings, in that case only YA.XXXX codes. I've tried some set analysis solutions but they didn't work. When I tried to use aggr() function, I got some results which were not correct. I could use max function for every one of master spendings but my table has so many rows , so that was impossible. If you help me, I would be glad.

Edit:

The formula I use is;

sum(aggr(max([Spendings]),Elements))

Labels (2)

• ### summation of max values

1 Solution

Accepted Solutions
New Contributor III

## Re: Summation of Max values in a column

In order to achieve that, I generated another field in my script as left(Elements,7) as MasterCode and instead of Elements, I used MasterCode in my "sum(aggr(max([Spendings]),Elements))" formula.

5 Replies
New Contributor III

## Re: Summation of Max values in a column

In order to achieve that, I generated another field in my script as left(Elements,7) as MasterCode and instead of Elements, I used MasterCode in my "sum(aggr(max([Spendings]),Elements))" formula.

MVP

## Re: Summation of Max values in a column

Not sure I understand right. Your expression looks in right path. Since that doesn't give right result, you could try :

`sum(aggr(NODISTINCT max([Spendings]),Elements))`
New Contributor III

## Re: Summation of Max values in a column

I tried to use left(Elements,7) in the expression and it didn't work but when I used the same expression in the script and saved as another field, that new field worked pretty well in the expression.

MVP

## Re: Summation of Max values in a column

That is because you can't use expression in aggr() as dimension but only script-generated field.
New Contributor III

## Re: Summation of Max values in a column

Thank you, that is really helpful for my possible applications in qliksense.