Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
SBDataspark
Creator
Creator

Calculate the percentage of sales for the year in a pivot table.

Hi there fellow Qlik enthousiasts!

I'm trying to calculate the percentage of sales per year in a pivot table.

Sebb_0-1657216327561.png

This pivot table is a simplification to make it easy to understand my question.
It shows quantity sold per item per customer or if you switch the two quantity sold per customer per item.

Now I'd like to calculate the percentage quantity sold compared to the total quantity sold for every year.

I'm trying all sorts of variants of this expression:

=Sum([Transactions.Quantity])
/
Sum(total [Transactions.Quantity])

But I can't get this to work.
In the screenshot I've added the correct percentage by hand.
So item "Ball" is 28,9% instead of 14% for the year 2021 instead of 14%. That's the percentage for all the years.

When I select a year it obviously shows the right percentage, because the dataset is limited to one year.

Sebb_1-1657216780386.png

What do I need to change to my expression to make this work correctly regardless of the order of dimensions and the selection made on the table?
Thanks!

Kind regards,

Sebb.

 

Labels (2)
1 Solution

Accepted Solutions
SBDataspark
Creator
Creator
Author

Hi @tincholiver,

Thank you for your efforts in trying to help me with this question.
I managed to find the answer.
This is de expression that I created to make it work:

=Sum([Transactions.Quantity])
/
Sum(total <[TransactionDate.autoCalendar.Year]> [Transactions.Quantity])

Sebb_0-1657292926488.png

Kind regards,

Sebb.

 

View solution in original post

3 Replies
tincholiver
Creator III
Creator III

did u try using aggr?

like this Agrr(sum(Sum([Transactions.Quantity]),dimension_1,dimension2)

tincholiver
Creator III
Creator III

sorry is

Agrr(Sum([Transactions.Quantity]),dimension_1,dimension2)

SBDataspark
Creator
Creator
Author

Hi @tincholiver,

Thank you for your efforts in trying to help me with this question.
I managed to find the answer.
This is de expression that I created to make it work:

=Sum([Transactions.Quantity])
/
Sum(total <[TransactionDate.autoCalendar.Year]> [Transactions.Quantity])

Sebb_0-1657292926488.png

Kind regards,

Sebb.