
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using an aggregated value for all of the values of the same Aggr()
Hello!
Sorry for the confusing title, I think an example will makes things a little easier.
Let's say I have this table:
Customer | Day | Sales |
---|---|---|
A | 1 | 20 |
B | 2 | 30 |
C | 3 | 15 |
A | 4 | 25 |
B | 5 | 35 |
And now I add the the aggreggation of the sum sales based on customer (syntaxis might be wrong, doing it from memory) aggr(sum(sales),Customer), that leaes me with the following table:
Customer | Day | Sales | Aggr |
---|---|---|---|
A | 1 | 20 | 45 |
B | 2 | 30 | 65 |
C | 3 | 15 | 15 |
A | 4 | 25 | - |
B | 5 | 35 | - |
So as you can see, when aggregating my table puts the value only in the first Customer it finds(or I don't know the logic behind), if I wanted to do something like a new column Sales/Aggr the output would be the following one:
Customer | Day | Sales | Aggr | Ratio |
---|---|---|---|---|
A | 1 | 20 | 45 | 0.44 |
B | 2 | 30 | 65 | 0.46 |
C | 3 | 15 | 15 | 1 |
A | 4 | 25 | - | - |
B | 5 | 35 | - | - |
So some columns won't calculated... Ideally what I would like is to have the aggregation of the sum repeated on each value 'Customer' that corresponds to.
Thank you!
- Tags:
- aggr
- pivotal table
- sum
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need a NODISTINCT within aggr(), like:
aggr( NODISTINCT sum(sales),Customer)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You are almost there just use sum() before your aggr()
like sum(aggr(sum(sales),Customer))
Regards,
Prashant
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need a NODISTINCT within aggr(), like:
aggr( NODISTINCT sum(sales),Customer)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This worked!
Thank you very much .
