cancel
Showing results for
Did you mean:
Frequent Visitor

## How to get Minimum price Supplier name?

Hi Friends

This is Nagarjuna. I Have a small query, Can u please help me on this?

 *Required Column Item Code Supplier Name Supplier Price Item Minimum Price Minimum Price Supplier 101 A 1 1 A 101 B 2 1 A 101 C 3 1 A 101 D 4 1 A 101 E 5 1 A 102 F 6 6 F 102 G 7 6 F 102 H 8 6 F 102 I 9 6 F 102 J 10 6 F 102 K 11 6 F 103 L 12 12 L 103 M 13 12 L 103 N 14 12 L 103 O 15 12 L 103 P 16 12 L 103 Q 17 12 L 103 R 18 12 L 104 S 19 19 S 104 T 20 19 S 104 U 21 19 S 104 V 22 19 S 104 W 23 19 S

How do i get the minimum price supplier name in a seperate column.

Warm regards

Nagarjuna

1 ACCEPTED SOLUTION

Accepted Solutions

## Re: How to get Minimum price Supplier name?

You can download the test file here: https://www.dropbox.com/s/gz881qnwd3dedfa/CheapestSupplier.pbix?dl=0

Have fun with DAX!

Alberto Ferrari
http://www.sqlbi.com

Alberto Ferrari - SQLBI
14 REPLIES 14
Highlighted
Established Member

## Re: How to get Minimum price Supplier name?

Hi @Nagarjunav,

Please try this measure with my table named Data:

```Test =
LOOKUPVALUE (
Data[Supplier Name],
Data[Supplier Price], MIN ( Data[Item Minimum Price] )
)```

Please ley us know if you have any observations...

Ninter

Super User

## Re: How to get Minimum price Supplier name?

Hi,

Can there be a case where the minimum price is the same for the same Item code but supplied by different suppliers.  For e.g. supplier A and C both have a price of 1for item code 101.  If this is a possibility, then what result would you want?  Please clarify.

Frequent Visitor

## Re: How to get Minimum price Supplier name?

Thank you Mr. Interkoubess, it worked perfectly when suppliers supplied at unique prices. As told by the Ashish_Mathur there could be a chance that different suppliers can supply for the same price, in that case it is not working. It is showing the below error

A table of multiple values was supplied where a single value was expected.

Suppose if one item was supplied at the same price by the different suppliers, then the answer shall be the supplier who supplies more quantity and if the quantity is also same, any one of them is ok for me

Now i am changing the data for better understanding

Please find the below table

 *Require Column Transaction ID Item Code Supplier Name Supplier Price Qty Item Minimum Price Minimum Price Supplier 1 1001 A 1 100 1 B 2 1001 A 1 200 1 B 3 1001 B 1 350 1 B 4 1001 C 3 100 1 B 5 1001 C 3 500 1 B 6 1001 D 4 100 1 B 7 1001 E 5 100 1 B 8 1002 F 6 100 6 F 9 1002 F 6 100 6 F 10 1002 F 6 100 6 F 11 1002 G 7 100 6 F 12 1002 G 7 150 6 F 13 1002 G 7 200 6 F 14 1002 H 8 300 6 F 15 1002 H 8 300 6 F 16 1002 H 8 300 6 F 17 1002 I 9 500 6 F 18 1002 J 10 300 6 F 19 1002 K 11 100 6 F 20 1003 L 13 200 12 M 21 1003 L 13 200 12 M 22 1003 L 13 200 12 M 23 1003 M 12 100 12 M 24 1003 M 12 100 12 M 25 1003 M 12 100 12 M 26 1003 N 14 100 12 M 27 1003 O 15 100 12 M 28 1003 P 16 100 12 M 29 1003 Q 17 100 12 M 30 1003 R 18 100 12 M 31 1004 S 19 100 19 U 32 1004 S 19 100 19 U 33 1004 S 19 200 19 U 34 1004 T 20 200 19 U 35 1004 U 19 200 19 U 36 1004 U 19 200 19 U 37 1004 V 22 300 19 U 38 1004 W 23 400 19 U

For the item code 1001 the minimum price is 1,

Two suppliers A&B supplied at 1,

B supplied 350 units but supplied only 300 units , So the answer should be "B" for item code 1001

For the item code 1002 the minimum price is 6,

Only supplier F supplied at 6, So the answer should be "F"  for the item code 1002

For the item code 1003 the minimum price is 12,

Only supplier M supplied at 12, so the answer should be "M" for the item code 1003

For the item code 1004 the minimum price is 19

Two Suppliers S&U supplied at 19,

Both suppliers supplied the same quantity of 400 units, in that case answer shall be S/U, but it should same for all the transactions

Please let me know if clarification needed?

Regards

Nagarjuna

## Re: How to get Minimum price Supplier name?

Well, that was a nice one!

This works as a calculated column, it is somewhat intricated, but it will return the first supplier based on the quantity sold and the supplier name who sold at the min price:

```CheapestSupplier =
VAR MinPrice =
CALCULATE (
MIN ( Trans[Supplier Price] ),
ALLEXCEPT ( Trans, Trans[Item Code] )
)
VAR Suppliers =
CALCULATETABLE (
VALUES ( Trans[Supplier Name] ),
"SuppliedQty", CALCULATE ( SUM ( Trans[Qty] ) )
),
ALLEXCEPT ( Trans, Trans[Item Code] ),
Trans[Supplier Price] = MinPrice
)
VAR TopSupplier =
TOPN ( 1, Suppliers, [SuppliedQty], DESC, Trans[Supplier Name], ASC )
RETURN
CONCATENATEX ( TopSupplier, Trans[Supplier Name], ", " )```

Please note that the quantity sold does not depend on the price, supplier A might have sold you something at 200, then some at 300 and the two values will be summed together to determine if he's the best one.

Youc an adapt it to consider only the quantity at the lowest price, or modify the code to compute slightly differnt calculations, the core should remain the same.

Have fun with DAX!

Alberto Ferrari
http://www.sqlbi.com

Alberto Ferrari - SQLBI
Super User

## Re: How to get Minimum price Supplier name?

Hi @Nagarjunav,

Can you answer my question please.  I believe you did post a reply but when i click on that link, i do not see your response.  Did you delete your response?

## Re: How to get Minimum price Supplier name?

I think he removed it. I was answering that post (he published some data with duplicates, that made the problem much more interesting) and the forum told me the message was no longer there. Thus, I replied to the main topic, even if I used data from that deleted message to do some tests.

Have fun with DAX!

Alberto Ferrari
http://www.sqlbi.com

Alberto Ferrari - SQLBI
Frequent Visitor

## Re: How to get Minimum price Supplier name?

Supplier price will be same for all transactions because i was added Average price column. My caluculations will be on average price only. Thedata was very big thats why i was given small data. If we get solution for this sample data thats enough for me.

First it should check for the lowest price supplier, if conflicts then only it should check the quantity.

And the supplier price (Particular supplier price) will same for all the transactions for that particular item

I was not deleted my post, i don't know why it was gone

Here is my original post.

Thank you Mr. Interkoubess, it worked perfectly when suppliers supplied at unique prices. As told by the Ashish_Mathur there could be a chance that different suppliers can supply for the same price, in that case it is not working. It is showing the below error

A table of multiple values was supplied where a single value was expected.

Suppose if one item was supplied at the same price by the different suppliers, then the answer shall be the supplier who supplies more quantity and if the quantity is also same, any one of them is ok for me

Now i am changing the data for better understanding

Please find the below table

 *Require Column Transaction ID Item Code Supplier Name Supplier Price Qty Item Minimum Price Minimum Price Supplier 1 1001 A 1 100 1 B 2 1001 A 1 200 1 B 3 1001 B 1 350 1 B 4 1001 C 3 100 1 B 5 1001 C 3 500 1 B 6 1001 D 4 100 1 B 7 1001 E 5 100 1 B 8 1002 F 6 100 6 F 9 1002 F 6 100 6 F 10 1002 F 6 100 6 F 11 1002 G 7 100 6 F 12 1002 G 7 150 6 F 13 1002 G 7 200 6 F 14 1002 H 8 300 6 F 15 1002 H 8 300 6 F 16 1002 H 8 300 6 F 17 1002 I 9 500 6 F 18 1002 J 10 300 6 F 19 1002 K 11 100 6 F 20 1003 L 13 200 12 M 21 1003 L 13 200 12 M 22 1003 L 13 200 12 M 23 1003 M 12 100 12 M 24 1003 M 12 100 12 M 25 1003 M 12 100 12 M 26 1003 N 14 100 12 M 27 1003 O 15 100 12 M 28 1003 P 16 100 12 M 29 1003 Q 17 100 12 M 30 1003 R 18 100 12 M 31 1004 S 19 100 19 U 32 1004 S 19 100 19 U 33 1004 S 19 200 19 U 34 1004 T 20 200 19 U 35 1004 U 19 200 19 U 36 1004 U 19 200 19 U 37 1004 V 22 300 19 U 38 1004 W 23 400 19 U

For the item code 1001 the minimum price is 1,

Two suppliers A&B supplied at 1,

B supplied 350 units but supplied only 300 units , So the answer should be "B" for item code 1001

For the item code 1002 the minimum price is 6,

Only supplier F supplied at 6, So the answer should be "F"  for the item code 1002

For the item code 1003 the minimum price is 12,

Only supplier M supplied at 12, so the answer should be "M" for the item code 1003

For the item code 1004 the minimum price is 19

Two Suppliers S&U supplied at 19,

Both suppliers supplied the same quantity of 400 units, in that case answer shall be S/U, but it should same for all the transactions

Please let me know if clarification needed?

Regards

Nagarjuna

Frequent Visitor

## Re: How to get Minimum price Supplier name?

@Ashish_Mathur

I was not deleted my post, i don't know why it has gone. I was reposted above please have a look

Thank you

## Re: How to get Minimum price Supplier name?

Ok, but you forgot to tell us the most important thing: did you solve your scenario?

Thanks.

Have fun with DAX!

Alberto Ferrari
http://www.sqlbi.com

Alberto Ferrari - SQLBI