Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Top Suppliers for 80% Spend

Hello everyone,

I have these transactions data.

   

ProductSupplierSpend
Product ASupplier 12000
Product ASupplier 21200
Product ASupplier 3700
Product ASupplier 4500
Product ASupplier 5500
Product ASupplier 6400
Product ASupplier 7350
Product ASupplier 8325
Product ASupplier 9250
Product ASupplier 10200
Product BSupplier 12000
Product BSupplier 21500
Product BSupplier 3750
Product BSupplier 1700
Product BSupplier 2700
Product BSupplier 3400
Product BSupplier 4650
Product BSupplier 5200
Product BSupplier 6100
Product CSupplier 1250
Product CSupplier 2250
Product CSupplier 3200
Product CSupplier 4200
Product CSupplier 5150

I would like to create this following report (in pivot table or table). I can't seem to get the last column, which is the count (distinct) of Suppliers contributing up to 80% of the spend for each Product.

     

ProductSpend# of Suppliers (Distinct)80% Spend# of Suppliers (Distinct - 80% Spend)
Product A64251051405
Product B7000656403
Product C105058403

Could anyone please help advise me on what expressions should i use to get that last column? Many thanks in advance!

11 Replies
Not applicable
Author

Seems that you are right on that note. My real data definitely doesn't come already sorted like the sample above. Moreover, I found that if we have 1 big supplier that has >80% of spend, then the count of supplier is 0 (which should be 1 in real case).

Digvijay_Singh

The work around to show 1 big supplier is as below -

Aggr(

  Count(

  if(Aggr(top(Sum(Spend)/Sum(Total<Product>Spend)),Product)>0.8,1,

  if(Aggr(Rangesum(Above(Sum(Spend)/Sum(Total<Product>Spend),0,Rowno())),Product,Supplier)<=0.8,Supplier))

  )

  ,Product)

But I suppose the expression will still exclude last supplier above 80% in the situation when 4 suppliers contribute 79% or so and adding one more goes above 80%. The last one won't be counted.

You would need to sort tables spend wise in the script to make it work as swuehl‌ pointed out.(Thanks!)

I tried to use new sortable Aggr function but I think it doesn't allow expression based sorting(Sum(Spend)).

See the attached sample where I changed the script to sort the table spend wise, surprisingly I need to change the Supplier field name to see the 'Order By' impact when doing resident load of old table, swuehl can you pl help to understand this, Is it related to unchanged symbol table order for supplier,not sure

Capture.JPG