Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
rudywelvaert
Creator
Creator

Percentage with AGGR function

Hi,

I have a table with 3 columns: Month,Group,Number

If I make a pivot table with Month, Group and Sum(Number) I get this:

    

Counting
MonthGroupABCTotal
1 3920059
2 0371148
3 395718114
4 9362570
5 28363195
6 19362176
7 25452696
8 27132262
9 1911737
10 30143377
11 2019746
12 27511997
Total 282365230877

But I want a percentage table where every value Sum(Number)  is divided by the total per month

e.g. Month = 1, Group = 1 -> 39/59 =0.6610 = 66.10%


So the table I get is thus:

    

Counting Percentage
MonthGroupABCTotal
1 66,10%33,90%0,00%100,00%
2 0,00%77,08%22,92%100,00%
3 34,21%50,00%15,79%100,00%
4 12,86%51,43%35,71%100,00%
5 29,47%37,89%32,63%100,00%
6 25,00%47,37%27,63%100,00%
7 26,04%46,88%27,08%100,00%
8 43,55%20,97%35,48%100,00%
9 51,35%2,70%45,95%100,00%
10 38,96%18,18%42,86%100,00%
11 43,48%41,30%15,22%100,00%
12 27,84%52,58%19,59%100,00%
Total 32,16%41,62%26,23%100,00%

Probably the Aggr function should be used for this, but how?

Anybody who has an idea.

Included Aggr.qvw with the data and two pivot tables: one with the sum and one where I would like the percentages

Thanks

R.W.

5 Replies
Miguel_Angel_Baeyens

Looks good, you can also simplify it using

Sum(TOTAL <Month> Number)

instead of using Aggr(). What is wrong there? The lack of 0%? If you don't have data it's a null and it will not show a 0 anyway (unless you create new data in the script).

sunny_talwar

Try this

=Sum(Number)/Sum(TOTAL <Month> Number)

Capture.PNG

rudywelvaert
Creator
Creator
Author

Thanks Miguel

rudywelvaert
Creator
Creator
Author

Thanks Sunny

Miguel_Angel_Baeyens

By the way, if you want to display the zeroes, go to the chart properties > Presentation and uncheck "Suppress Zero-Values"