Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
PabloOrtiz
Partner - Creator
Partner - Creator

Aggr Problem

Hi, I'm having problems with calculating a Aggr Sum which in theory is simple. The case is as follows:

I have the following table:

Table:

load * Inline [

KeyUH, State Amount

A,1,1000

A ,2,1000

A ,3,4500

B, 1,1000

B, 2,1000

B, 3,7000

B, 4,9000

];

Just need the sum of the amount KeyUH field when the state is the maximum, that is:

A, 3,4500 (3 is the highest state for A)

B, 4,9000 (4 is the highest state B)

and result in 4.500 + 9.000 = 12.500

I am using the following expression: aggr (sum ({<Status = {"$ (= max (State))"}>} Amount) KeyUH)

It does not work properly

Thanks in advance.

1 Solution

Accepted Solutions
nagaiank
Specialist III
Specialist III

The following expression works:

=Sum(Aggr(FirstSortedValue(Amount,-State),KeyUH))

View solution in original post

3 Replies
nagaiank
Specialist III
Specialist III

The following expression works:

=Sum(Aggr(FirstSortedValue(Amount,-State),KeyUH))

maxgro
MVP
MVP

=sum(aggr(FirstSortedValue(TOTAL <KeyUH> Amount, -State), KeyUH))

PabloOrtiz
Partner - Creator
Partner - Creator
Author

Thanks NagaianK, that's what I was looking for.

Regards.