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

Percentage per month over any number of years

Hello,

I've got the following table:

Month201320142015Amount
11000150018004300
21100160018304530
31200180018404840
41050151018504410
51070152018604450
61250155018004600
71300156018004660
81200151019004610
91100210018205020
101030180025005330

11

1000160021004700
121100155030005650
Sum13400196002410057100

I want to calculate the percentage of every month over all years. As far as I can tell there are two ways to do this.

1.) I sum up all years per month and divide them by the total of all months.

So, the calculation for December would be 5650 / 57100 * 100 = 9.89%.

I figured out how to do this in QlikView.

It would look something like this:

sum({$ <Year = {2013, 2014, 2015}>} Amount) / sum(total {$ <Year = {2013, 2014, 2015}>} Amount)

2.) The second way is a little different, but this is the one I want to go with:

Calculate the percentage of each year, sum it all up an then divide the result by the number of years.

Again, for December:

1100 / 13400 * 100 = 8.21%

1550 / 19600 * 100 = 7.91%

3000 / 24100 * 100 = 12.45%

Sum up and divide:

(8.21 + 7.91 + 12.45) / 3 = 9.52%

Is there any way I can do that in QlikView without manually summing up every year?

Thank you!

1 Solution

Accepted Solutions
sunny_talwar

That looks incomplete.... should it be this?

Avg(Aggr(Sum({$<Year = {2013, 2014, 2015}>} Amount)/Sum(TOTAL <Year> {$ <Year = {2013, 2014, 2015}>} Amount), Year, Month))

View solution in original post

6 Replies
sunny_talwar

Try this

Sum({$<Year = {2013, 2014, 2015}>} Amount)/Sum(TOTAL <Year> {$ <Year = {2013, 2014, 2015}>} Amount)

Kushal_Chawda

for second requirement

=avg(aggr(sum(Amount)/sum(total Amount),Year))

sunny_talwar

That looks incomplete.... should it be this?

Avg(Aggr(Sum({$<Year = {2013, 2014, 2015}>} Amount)/Sum(TOTAL <Year> {$ <Year = {2013, 2014, 2015}>} Amount), Year, Month))

Not applicable
Author

Thank you. That worked!

Not applicable
Author

One more question:

Can I somehow make the selection of the year flexible? I've got a list box, and the User should be able to choose the years that are calculated.

I tried

Avg(Aggr(Sum({$<Year = {">=$(min(Year))<=$(max(Year))"}>} Amount)/Sum(TOTAL <Year> {$ <Year = {">=$(min(Year))<=$(max(Year))"}>} Amount), Year, Month))


but that doesn't seem to work. I think I know, why it doesn't work, but I can't think of any other way to do it right.

sunny_talwar

May be try just this

Avg(Aggr(Sum(Amount)/Sum(TOTAL <Year> Amount), Year, Month))