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

Showing the lowest value and which customer it relates to in Script

From the previous thread

Re: Returning seller name where selling price is the lowest.

I believe i now need this done within the script as i want to count the number of results where a customer has the lowest price.

The following however, gives me a minimum Price for each customer for [Common Name] but i only want the lowest Price for the [Common Name] and whichever [Customer] that would be. Am i on the right track here or does it need to be done a different way?

CustomerMIN:
Load
[Customer],
[Common Name],
Min([Unit Price]) as MINPRICE

Resident Data
where "Exclude" = 'No' and [International] = 'Yes'
Group by [Customer],[Common Name];

11 Replies
ksharpes
Creator
Creator
Author

I thought it was ^^

This sort of works, however if the lowest Unit Price occurs more than once in the data it does not show the Seller with Lowest Price, the value is instead blank.

(Like below)

ProductPriceSellerVolumeMin PriceSeller with Lowest Price
Product 11.1Seller A11001.1 
Product 11.1Seller A11501.1 
Product 11.2Seller A12001.1 
Product 11.2Seller B12001.1 
Product 11.25Seller B12501.1 
Product 11.3Seller B13001.1 
Product 11.3Seller C13001.1 
Product 11.35Seller C13501.1 
Product 11.4Seller C14001.1 
Product 21.1Seller A11001.0Seller C
Product 21.15Seller A11501.0Seller C
Product 21.2Seller B12001.0Seller C
Product 21.25Seller B12501.0Seller C
Product 21.0Seller C10001.0Seller C
Product 21.35Seller C13501.0Seller C

 

sunny_talwar

Change this

FirstSortedValue(Seller, Price) as [Seller with Lowest Price]

to

FirstSortedValue(DISTINCT Seller, Price) as [Seller with Lowest Price]

 

But if two sellers provide the lowest price? What would you want to see then?