Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for
Search instead for
Did you mean:
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
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))

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

Contributor III
Author

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

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

Community Browser