Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
pauldamen
Partner - Creator II
Partner - Creator II

Aggr monthly balances per year

All,

I have monthly balances with a starting balance in January, the rest of the year are changes to this balance. So in order to show correct numbers I need to show the balances per month aggr for that year. The table looks like this (in the 3rd kolom I have show what I need):

jan-15      10.000          10.000

feb-15          500           10.500

mrt-15         -500           10.000

apr-15          750            10.750

may-15         500          11.250

jun-15       -1.250          10.000

jul-15          500              10.500

aug-15         500             11.000

sep-15          500            11.500

oct-15        -1.500          10.000

nov-15      250               10.250

dec-15       250                10.500

jan-16     10.000              10.000

I tried this formula: sum(Aggr(sum(Amount), Year)). But this shows me numbers only in january not the rest of the months. How can I achieve what i want?

Regards, Paul

1 Solution

Accepted Solutions
sunny_talwar

If you have a monthfield created in the script like this -> Month(DateField) as Month, you can try this:

RangeSum(Above(Sum(Amount), 0, Num(Month)))

View solution in original post

15 Replies
marcus_sommer

Try it with: rangesum(sum(Amount), 0, rowno())

- Marcus

pauldamen
Partner - Creator II
Partner - Creator II
Author

What would I get for outcome? My table starts on september 2013, so that should aggr for 4 months and then start in january of each year again till the end of the year.

If I use your suggestion this still gives me different numbers since the january start is not taken into account?

jonathandienst
Partner - Champion III
Partner - Champion III

I assume you mean in a table/chart in the front end. Use an expression like:

=RangeSum(Above(Sum(Balance), 0, RowNo()))

Replace "Sum(Balance)" with the expression for balance, or with Column(1) if balance is in the first expression. Use in a table or chart witha year/month dimension as in your post,

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

>>What would I get for outcome? My table starts on september 2013, so that should aggr for 4 months and then start in january of each year again till the end of the year.

You would be best off doing this in script rather than doing it in the front end. But if you can't do that, then use Month as a dimension and select the year in a list box or set expression, and it will always start the accumulation from the first month of the year.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
christophebrault
Specialist
Specialist

Hi,

Marcus, I think with RangeSum you must use Above like this :

RangeSum(Above(sum(Amount), 0, rowno()))

Inscrivez vous à ma Newletter Qlik
DoNotMissQlik- Connect with me on Linkedin
pauldamen
Partner - Creator II
Partner - Creator II
Author

What do you mean with sum(balance)?

With the above formula I just get my booking every month, it is not accumulating

pauldamen
Partner - Creator II
Partner - Creator II
Author

Hi Christophe,

With adding the Above it worked!

But how can I limit the formula per year? So I starts off in january not taking the previous year(s) in account?

sunny_talwar

Try this:

=RangeSum(Above(Sum(Amount), 0, RowNo()))


or if you have multiple dimensions and you want full accumulation on all your dimensions


=RangeSum(Above(TOTAL Sum(Amount), 0, RowNo(TOTAL)))

jonathandienst
Partner - Champion III
Partner - Champion III

>>What do you mean with sum(balance)?

Well you haven't posted an example, or any details on your existing expression, that's why I said

"Replace "Sum(Balance)" with the expression for balance"

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein