cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Nagarjunav Frequent Visitor
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 CodeSupplier NameSupplier PriceItem Minimum PriceMinimum Price Supplier
101A11A
101B21A
101C31A
101D41A
101E51A
102F66F
102G76F
102H86F
102I96F
102J106F
102K116F
103L1212L
103M1312L
103N1412L
103O1512L
103P1612L
103Q1712L
103R1812L
104S1919S
104T2019S
104U2119S
104V2219S
104W2319S

 

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

 

Thanks in advance 

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
Interkoubess Established Member
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...

 

test.PNG

 

Ninter

Super User
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.

Nagarjunav Frequent Visitor
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 IDItem CodeSupplier NameSupplier PriceQtyItem Minimum PriceMinimum Price Supplier
11001A11001B
21001A12001B
31001B13501B
41001C31001B
51001C35001B
61001D41001B
71001E51001B
81002F61006F
91002F61006F
101002F61006F
111002G71006F
121002G71506F
131002G72006F
141002H83006F
151002H83006F
161002H83006F
171002I95006F
181002J103006F
191002K111006F
201003L1320012M
211003L1320012M
221003L1320012M
231003M1210012M
241003M1210012M
251003M1210012M
261003N1410012M
271003O1510012M
281003P1610012M
291003Q1710012M
301003R1810012M
311004S1910019U
321004S1910019U
331004S1920019U
341004T2020019U
351004U1920019U
361004U1920019U
371004V2230019U
381004W2340019U

 

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?

 

Thanks in advance

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 (
        ADDCOLUMNS (
            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
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
Nagarjunav Frequent Visitor
Frequent Visitor

Re: How to get Minimum price Supplier name?

Hi @Ashish_Mathur, @AlbertoFerrari

 

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 IDItem CodeSupplier NameSupplier PriceQtyItem Minimum PriceMinimum Price Supplier
11001A11001B
21001A12001B
31001B13501B
41001C31001B
51001C35001B
61001D41001B
71001E51001B
81002F61006F
91002F61006F
101002F61006F
111002G71006F
121002G71506F
131002G72006F
141002H83006F
151002H83006F
161002H83006F
171002I95006F
181002J103006F
191002K111006F
201003L1320012M
211003L1320012M
221003L1320012M
231003M1210012M
241003M1210012M
251003M1210012M
261003N1410012M
271003O1510012M
281003P1610012M
291003Q1710012M
301003R1810012M
311004S1910019U
321004S1910019U
331004S1920019U
341004T2020019U
351004U1920019U
361004U1920019U
371004V2230019U
381004W2340019U

 

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?

 

Thanks in advance

Regards 

Nagarjuna

Nagarjunav Frequent Visitor
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