Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Advance Set analysis help

Hi All,

I have below data set

DeliveryDate Per SupplierCode
2014-08-100.2A
2014-08-100.5B
2014-08-110.3B
2014-08-110.6A
2014-08-120.2A
2014-08-120.5B

Output I need is below

DeliveryDateCount
8/10/20141
8/11/20142
8/12/20141

Logic - I need to count the suppliers for particular Date, where per is greater than 0.2.

I am using below expression but it's giving wrong results

= Count({<SupplierCode={"=sum(Per)>0.2"}>} distinct SupplierCode)


gwassenaarstalwar1swuehl‌  kush141087

8 Replies
vinieme12
Champion III
Champion III

= Count({<DeliveryDate={"=sum(Per)>0.2"}>} distinct SupplierCode)


Try below

= Count({<Per={">0.2"}>} distinct SupplierCode)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Not applicable
Author

thanks for your reply

below is my actual data set

Data:

LOAD * Inline [

DeliveryDate,     Field1,Field2,     SupplierCode

2014-08-10,    20, 100,    A

2014-08-10,    50, 100,    B

2014-08-11,    30, 100,    B

2014-08-11,    60, 100,    A

2014-08-12,    20, 100,    A

2014-08-12,    50, 100 ,    B ] ;

Per is calculated as, sum(Field1)/sum(Field2)

I cannot directly do Field1/Field2 in script because of some data complexity. So I am trying below expression, but it's not working

=Count({<SupplierCode={"=(sum(Field1)/sum(Field2))>0.2"}>} distinct SupplierCode)

vinieme12
Champion III
Champion III

You need a key that identifies each row

Data:

LOAD *,Recno() as RowKEY Inline [

DeliveryDate,Field1,Field2,SupplierCode

2014-08-10,20,100,A

2014-08-10,50,100,B

2014-08-11,30,100,B

2014-08-11,60,100,A

2014-08-12,20,100,A

2014-08-12,50,100,B

];

Expression

= Count({<RowKEY={"=(sum(Field1)/Sum(Field2))>0.2"}>} distinct SupplierCode)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
MK_QSL
MVP
MVP

You can also use this..

SUM(Aggr(IF(SUM(Field1)/SUM(Field2)>0.2,1,0),DeliveryDate,SupplierCode))

MK_QSL
MVP
MVP

or create an ID field

Data:

LOAD

  AutoNumber(DeliveryDate & SupplierCode) as ID,

  *

Inline

[

  DeliveryDate,  Field1, Field2,  SupplierCode

  2014-08-10,    10, 100,    A

  2014-08-10,    10, 100,    A

  2014-08-10,    25, 100,    B

  2014-08-10,    25, 100,    B

  2014-08-11,    30, 100,    B

  2014-08-11,    10, 100,    A

  2014-08-11,    50, 100,    A

  2014-08-12,    20, 100,    A

  2014-08-12,    50, 100,    B

] ;

and use below expression

COUNT({<ID = {"=SUM(Field1)/SUM(Field2)>0.2"}>}DISTINCT ID)

MK_QSL
MVP
MVP

vinieme12‌ Good Solution.

But this will not give you correct total ..  Total must be 4 but it will give you 2.

Try your expression in Text Box ...!!

vinieme12
Champion III
Champion III

Yes, the same aggregation can be achieved with

= SUM(AGGR(Count({<RowKEY={"=(sum(Field1)/Sum(Field2))>0.2"}>} distinct SupplierCode),DeliveryDate,SupplierCode))

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
sunny_talwar

This was the solution I was going to recommend.... Basically create an ID field by combining those fields where you want to check for Sum(Field1/Sum(Field2) so that you can use set analysis. Otherwise Aggr() is the other option