# QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

New Contributor III

## Sum of aggr function

Hi,

I have a QV table with an expression that looks like below.

As you can see from the picture it doesn't seem to add upp in the column total and I can't figure out why.

The expression looks like this:

MålkortsDatum = Date formated as YYYY-MM-DD

SVDate (Variable) = 2018-10-30

SlutprognosAnsvar = number column (data from excelfile)

ProjektNr = number column (data from excelfile)

AnsvarNr = number column (data from excelfile)

FirstSortedValue({\$<MålkortsDatum={"<\$(SVDate)"}>} distinct aggr(Sum({1<MålkortsDatum={"<\$(SVDate)"}>}SlutprognosAnsvar), ProjektNr, AnsvarNr, MålkortsDatum),-MålkortsDatum)

1 Solution

Accepted Solutions
New Contributor III

## Re: Sum of aggr function

Thank you for the information Stefan,
I ended up rewriting the expression after getting a better understanding of the expressions and this is the end result:

Sum({\$<MålkortsDatum={"<\$(SVDate)"}>}AGGR(FirstSortedValue(SlutprognosAnsvar, -MålkortsDatum), ProjektNr, AnsvarNr))

4 Replies
MVP

## Re: Sum of aggr function

If you say 'add up' that means you want a sum of rows in your pivot table?

https://help.qlik.com/en-US/qlikview/November2017/Subsystems/Client/Content/ChartFunctions/NestedAgg...

Try adding the the Sum(Aggr(..., YourChartDimensions)) like

=Sum({\$<MålkortsDatum={"<\$(SVDate)"}>} Aggr(

FirstSortedValue({\$<MålkortsDatum={"<\$(SVDate)"}>} distinct aggr(Sum({1<MålkortsDatum={"<\$(SVDate)"}>}SlutprognosAnsvar), ProjektNr, AnsvarNr, MålkortsDatum),-MålkortsDatum)

,ProjektNr, AnsvarNr))

Highlighted
New Contributor III

## Re: Sum of aggr function

That is awesome!
Why does it work when using a second aggr argument?

MVP

## Re: Sum of aggr function

New Contributor III

## Re: Sum of aggr function

Thank you for the information Stefan,
I ended up rewriting the expression after getting a better understanding of the expressions and this is the end result:

Sum({\$<MålkortsDatum={"<\$(SVDate)"}>}AGGR(FirstSortedValue(SlutprognosAnsvar, -MålkortsDatum), ProjektNr, AnsvarNr))