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: 
PaulK
Contributor III
Contributor III

Finding cheapest supplier price using Range(Min) and then another column to show which supplier is the cheapest

Hi

I have a straight table with 5 different columns showing 5 different supplier prices for items we sell, with a column with the items SKU. See table below

Item SKU Supplier 1 Price Supplier 2 Price Supplier 3 Price Supplier 4 Price Supplier 5 Price
F001709-5G 17.29 45.2 17.29 11.4 -
F001709-10G 30.94 90.4 30.94 50.4 -
F003977-1G - - 41.86 32.2 29.99

 

I'm going to use 
RangeMin([Supplier 1 Price][Supplier 2 Price][Supplier 3 Price][Supplier 4 Price][Supplier 5 Price])
to add another column (Cheapest Price) showing the cheapest price for a SKU. But I then need another column showing which Supplier is the cheapest for that SKU and I'm not sure what is the best way to do this. See table below. 

Item SKU Supplier 1 Price Supplier 2 Price Supplier 3 Price Supplier 4 Price Supplier 5 Price Cheapest Price Cheapest Supplier
F001709-5G 17.29 45.2 17.29 11.4 - 11.4 Supplier 4
F001709-10G 30.94 90.4 31.25 50.4 - 30.94 Supplier 1
F003977-1G - - 41.86 32.2 29.99 29.99 Supplier 5
F003977-5G 160.16 99.6 141.96 109.2 - 99.6 Supplier 2

 

If anybody can suggest how I can display the Cheapest Supplier column on the right it would be much appreciated.

Thanks
Paul

Labels (2)
2 Replies
vikasmahajan

hi,

Do you have date column in your  model  you can use firstsortedvalue to achieve this

 

Sum(Aggr(FirstSortedValue(Price, Date), Vendor_id)) 

or

Last value: FirstSortedValue(Price, -Date)

First value: FirstSortedValue(Price, Date)

try some thing like this.

 

Vikas

 

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
PaulK
Contributor III
Contributor III
Author

Hi Vikas

I don't have a date column, I only have the prices from each supplier. 

37 Suppliers in total and I need to find the cheapest supplier for nearly 1.5 million items from those suppliers. 

Kind Regards

Paul