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

Returning seller name where selling price is the lowest.

Basically I would like to replicate the below table based on the sample data below it.

For Each Product I would like to show the seller name for the lowest price

Using the following expression only shows me the seller for the lowest price across all products, instead of the lowest seller for each product. 

Only({< Price = {$(=Min(Price))} >} Seller)

Product NameSeller with Lowest Price
Product 1Seller A
Product 2Seller A
Product 3Seller C
Product 4Seller C

 

 

Product NamePriceSeller
Product 11.1Seller A
Product 11.2Seller B
Product 11.3Seller C
Product 21.1Seller A
Product 21.2Seller B
Product 21.3Seller C
Product 31.1Seller A
Product 31.2Seller B
Product 31.0Seller C
Product 41.1Seller A
Product 41.2Seller B
Product 41.0Seller C
1 Solution

Accepted Solutions
sunny_talwar

Try this

Sum(Aggr(
  If(
    FirstSortedValue(DISTINCT TOTAL <[Product Name]> Seller, Price) = Seller, 
    Sum(Sales)
  )
, Seller, [Product Name]))

View solution in original post

12 Replies
sunny_talwar

Try this

 

FirstSortedValue(Seller, Price)

image.png

 

ksharpes
Creator
Creator
Author

Thanks looks like i needed to add in DISTINCT as sometimes the lowest value was the same across the same seller.

So the below does it.

FirstSortedValue(DISTINCT BU, Price)

 

If I want to add this value into a set expression how would i do that?

eg, if for the lowest seller of the product, how much are the total sales that seller has sold for that product?

 

 

sunny_talwar

Set analysis will not work... may be try this

Sum(Aggr(If(FirstSortedValue(TOTAL <BU> DISTINCT BU, Price) = BU, Sum(Sales)), BU, Invoice))
ksharpes
Creator
Creator
Author

What field should "Invoice" be?

sunny_talwar

I don't really know your data... but the idea is that a field that tells us how many items sold by a seller

ksharpes
Creator
Creator
Author

Ok I'm a little lost.

I have a field called "SALES" and I  want to get the total of this field for the product, for the Seller with the lowest sale price.

sunny_talwar

Can you share a sample data and output you expect to see from it... because I am equally lost here... without knowing what exactly you have... I am trying to give you a very generic solution... but if you want specifics, provide a better sample data just like you did initially.

ksharpes
Creator
Creator
Author

It would be like the below.

The Sales column would be to show how much the total sales was for the seller with the lowest price.

If i also wanted to do this based on the lowest Average price, would this be possible?

Product NameSeller with Lowest PriceSales
Product 1Seller A3450
Product 2Seller C2350

 

Product 11.1Seller A1100
Product 11.15Seller A1150
Product 11.2Seller A1200
Product 11.2Seller B1200
Product 11.25Seller B1250
Product 11.3Seller B1300
Product 11.3Seller C1300
Product 11.35Seller C1350
Product 11.4Seller C1400
Product 21.1Seller A1100
Product 21.15Seller A1150
Product 21.2Seller B1200
Product 21.25Seller B1250
Product 21.0Seller C1000
Product 21.35Seller C1350
sunny_talwar

Try this

Sum(Aggr(
  If(
    FirstSortedValue(DISTINCT TOTAL <[Product Name]> Seller, Price) = Seller, 
    Sum(Sales)
  )
, Seller, [Product Name]))