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: 
Not applicable

SUM IF MAX

Hi,

trying to show the end balance. Using the below does not work,

SUM(IF(SettlementOrder=(MAX( SettlementOrder)),Balance))

If I add the "TOTAL" it works, but I need this figure for each date.

SUM(IF(SettlementOrder=(MAX(TOTAL SettlementOrder)),Balance))

TOTAL gives me one single value (based on largest historical SettlementOrder-number)

Any clues?

Kind REgards,

Olle

15 Replies
tresesco
MVP
MVP

That should be little simpler

=FirstSortedValue(Amount, -SettlementOrder)

PFA

Not applicable
Author

Perfect!

Thank you Jagan!

IAMDV
Luminary Alumni
Luminary Alumni

Hi,

I suggest using FirstSortedValue() with the Aggr() functions. Attached the sample QVW with the expression.

I hope this helps!

EDIT: Little late to the party!

Cheers,

DV

www.QlikShare.com

Not applicable
Author

Hi again Jagan,

If I wanted to hardcode for specific clients, where would i put the

{ <Client= {'ClientName'}>} into the code? Cannot get it to work properly.



=SUM(Aggr(IF(SettlementOrder= (MAX(TOTAL <Date> SettlementOrder)), Sum(Balance)), Date, SettlementOrder))

Thansk in advance,

Olle

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

=SUM({ <Client= {'ClientName'}>} Aggr(IF(SettlementOrder= (MAX({ <Client= {'ClientName'}>} TOTAL <Date> SettlementOrder)), Sum({ <Client= {'ClientName'}>} Balance)), Date, SettlementOrder))

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

Works like a charm! Thanks