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: 
antonaks
Creator II
Creator II

Complex expression (count if sum...)

Hello dear community!
I have a problem with a complex expression.

It is necessary to count the number of documents in which the amount of sales is more than a certain number (> 50), as well as with the filter in SetAnalysis.

The difficulty is that the document in my array is not aggregated by unique.


As an example, the data looks like this:


    

ID_DOCID_SKUSumSaleFlag_1
11120
12250
13310
14460
233301
233321
21190
32270
344190
37730
388230
444431
43391
55520
51110
52270
52230

The solution I imagine is like this:


Count(DISTINCT ID_DOC)

where

Aggr(Sum(SumSale),ID_DOC) > 50

and

Flag_1=1

The result of the decision needs to be the number - 2, if we take the above example data.

Please help.

With respect Anton.

14 Replies
sunny_talwar

Set analysis is the way to go here

antonaks
Creator II
Creator II
Author

I can not implement it in the application.
The formula looks like this:


Count (DISTINCT {<DOC_FILIAL_KEY = {"= Sum ({$ <[CHANNEL NAME] - = {'Manufacturer'}, [DOCUMENT TYPE ID] = {2,7,10}, [CODE TYPE] = {1,2 , 4,15,19,20,27,28,29,30}, CM_TD = {1}>} ([AMOUNT WITH VAT] * [OPERATION TYPE])> 50 "} >} DOC_FILIAL_KEY)

sunny_talwar

Try now:

Count (DISTINCT {<DOC_FILIAL_KEY = {"=Sum({$<[CHANNEL NAME] -= {'Manufacturer'}, [DOCUMENT TYPE ID] = {2,7,10}, [CODE TYPE] = {1,2 , 4,15,19,20,27,28,29,30}, CM_TD = {1}>} ([AMOUNT WITH VAT] * [OPERATION TYPE])) > 50"}>} DOC_FILIAL_KEY)

antonaks
Creator II
Creator II
Author

I missed the bracket
Works 100 times faster !!!
Thank you very much!

sunny_talwar

Awesome