Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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.
Thanks in advance
Warm regards
Nagarjuna
Solved! Go to Solution.
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
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?
I was not deleted my post, i don't know why it has gone. I was reposted above please have a look
Thank you
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
@AlbertoFerrari, @Ashish_Mathur
No, i got an error while calculating 2nd formula i.e.
VAR Suppliers = CALCULATETABLE ( ADDCOLUMNS ( VALUES ( Trans[Supplier Name] ), "SuppliedQty", CALCULATE ( SUM ( Trans[Qty] ) ) ), ALLEXCEPT ( Trans, Trans[Item Code] ), Trans[Supplier Price] = MinPrice )
It is not working, showing the below error.
The expression contains multiple columns, but only a single column can be used in a True/False expression that is used as a table filter expression.
Can you please recheck the solution in Power BI, I mean can you provide the solution screenshot.
And one thing i want to tell you, In my case supplier price( I mean one supplier price) will be same for all transactions for that item code
Eg: Supplier A supplied at $1 for the item code 1001 . We may have 1000 transactions with supplier A for the item code 1001, but he will supply at $1 only.
Supplier C supplied at $3 for the item code 1001. We may have 2000 transaction with supplier C for the item code 1001, but he will supply at $3 only.
Thank You
Regards
Nagarjuna
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
Thank you @AlbertoFerrari
I made a mistake that's why i got an error, sorry for that.
Now its worked without error but i got blanks in some rows (Almost in 50% rows). Can you Please tell me what could be the reason?
Thank you
Regards
Nagarjuna
Without looking at the data? No way... Likely, there's a bug somewhere in the code, but I would need some test data to find it. If you can share some sample data where the errors spots, then I can take a look at it.
Have fun with DAX!
Alberto Ferrari
http://www.sqlbi.com
Thank you @AlbertoFerrari
Now its working, I changed formula according to my requirements.
Now i am checking with my report which i have done it in excel. If i found any deviations i will get back to you with the sample data, otherwise i will accept it as a solution.
Once again thank you so much
Regards
Nagarjuna
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 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?
Thanks in advance
Regards
Nagarjuna
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
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
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?
Thanks in advance
Regards
Nagarjuna
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.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |