10 Replies Latest reply: Apr 16, 2015 1:49 PM by Massimo Grossi

# sum(Amount) with lastest version of every Key

Hi Guys,

can you tell me, how can I use sum(Amount) by KeyNr, within the last version of it in backend?

I want for example sum(amount) all KeyNr from periode january to july ..

like:

sum(amount)->within only max(version)

• ###### Re: sum(Amount) with lastest version of every Key

try set Analysis

sum({<version={'\$(=max(version)'}>}amount

• ###### Re: sum(Amount) with lastest version of every Key

it didnt work

sum({<VersH={'\$(=max(VersH)'}>}LineAmountA)

edit:

money(sum({<VersH={\$(=max(VersH))}>}LineAmountA))

works now without '..'

• ###### Re: sum(Amount) with lastest version of every Key

can you post how your Detail data looks like and what should be expected result?

• ###### Re: sum(Amount) with lastest version of every Key

Now I have the problem, that the versionnr arent the same, by keynr ..

some keynr has version 5 as max, other version 3 as max(version),

so how can I set all max version of several keynr?

• ###### Re: sum(Amount) with lastest version of every Key

sorry I donot understand your requirements

can you post a small example application?

• ###### Re: sum(Amount) with lastest version of every Key
KeynrVersHmax(version) of each Keynr->sum(LineAmountA)
123
243
3545
464
476
544
554
565

this is the table what I#ve got:

if I use :

money(sum({< VersH={\$(=max(VersH))}>}LineAmountA))

It only shows/sum the key within max(versH) --> in this example =7

..

so, how can I sum all the key with their max(Versh) ?

to get this:

Keynr VersH sum... 1 2 3 2 4 3 3 5 45 4 7 6 5 6 5
• ###### Re: sum(Amount) with lastest version of every Key

I used a small inline table with your data and I got your final table

please have a look if that's what you want

• ###### Re: sum(Amount) with lastest version of every Key

nearly..

what I need to sum is not 74.

I need:

3+3+45+5+6=62

• ###### Re: sum(Amount) with lastest version of every Key

aggr(max(Amount),KeyNr)

• ###### Re: sum(Amount) with lastest version of every Key

sum(aggr(subfield(concat(Aggr(sum(Amount), KeyNr, VersH), '@', -VersH), '@', 1),  KeyNr))