Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
patrickbender
Contributor III
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
patrickbender
Contributor III
Contributor III
Author

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))

View solution in original post

4 Replies
swuehl
MVP
MVP

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))

patrickbender
Contributor III
Contributor III
Author

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

patrickbender
Contributor III
Contributor III
Author

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))