Skip to main content
Announcements
Qlik Launches Open Lakehouse and advanced agentic AI experience in Qlik Answers! | LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
pedrohenriqueperna
Creator III

Sum sold quantity for different prices for a same product SKU

Hello!

I've been asked to display the sold quantity of a product SKU for different price ranges this SKU have been sold.

The problem is that I need to display the different prices in columns, instead of lines. It means that for each Price column I need a corresponding column for the quantity, as shown in the picture below (expected result).

 

5c61788277a61d84febdb028c011b19f.png

 

Each product has a same "reference code" that might hold different SKUs and a different "Original Price" (the first price registration).

The data model already holds a field record for each different price the product was sold, with that said I managed to show the different prices using FirstSortedValue by specifying the rank order (1 for Price 1 / 2 for Price 2 / etc.), but I can't make the calculation correspond to the Price X, it either sums everything or it shows only for 1 line if I add FirstSortedValue inside a set analysis.

 

I assume I have to work with Aggr and Sum. I tried different combinations, but I just can't get it to work.

The closest I got was this, but it only shows the correct value for a single line:

Sum({<NFTipoMovimento = {'Venda'}, PrecoEpoca = {"$(=(FirstSortedValue(Distinct PrecoEpoca, PrecoEpoca, 1)))"} >} [ProdutoQuantidade])

 

PS:

PrecoEpoca = Different price ranges the product has been sold

ProdutoQuantidade = Units solds

ProdutoReferencia = Reference code (1 level above SKU)

%ProdutoSKU = SKU code

PrecoOriginal = First price registration for that SKU

 

Any help is appreciated.

SOS

Labels (2)
1 Solution

Accepted Solutions
Or
MVP

Perhaps I am misunderstanding your data structure, but if you have a list of sales lines, and each of them has a quantity and a price, wouldn't this be a pivot table with the Price field as the pivot dimension?

View solution in original post

2 Replies
Or
MVP

Perhaps I am misunderstanding your data structure, but if you have a list of sales lines, and each of them has a quantity and a price, wouldn't this be a pivot table with the Price field as the pivot dimension?

pedrohenriqueperna
Creator III
Author

Hey!

Thank you for the reply.

It crossed my mind to use a pivot table, but I thought it wouldn't give me the expected result.

I've just played a bit with it and I think it might be the solution indeed.

Thanks for the tip!!!