Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Ciria
Advocate III
Advocate III

LookUpValue Function -- Error

Dears:

 

I have a table, named "Receptions", where material receptions information from multiples supplier and items are stored.

For trazeability issues, every supplier batch needs a internal batch. Of course we try to limit the amount of batches, but sometimes it happens.

In the below (and simple) example you can see the Product 1 has been received last time on July 06th, but two batches were received from Supplier 1.

 

Receptions Table(Fact Table)     
ProductDatePriceBatchSupplier batchSupplierQuantity
Product 106/07/20162,45Lot-001Batch 2016-1Supplier 1250
Product 106/07/20162,47Lot-002Batch 2016-2Supplier 1250
Product 105/04/20162,48Lot-003Batch 2016-3Supplier 1500

 

This is how the table I have created looks like in PowerBI.

 

Receptions Summary Table

Supplier NameFull NameTotal Purchases (%) FamilyLast PurchaseLast Purchase PriceTotal AmountAverage of Unit Price € (Exchange Insurance)
Supplier 1Product 181,59%06/07/2016 0:00 181652,52
Supplier 1Product 228,30%21/06/2016 0:00 1669410,28
Supplier 1Product 399,69%23/05/2016 0:00 160001,81
Supplier 1Product 454,86%16/03/2016 0:00 150701,23
Supplier 1Product 587,19%19/07/2016 0:00 129652,96
Supplier 1Product 625,92%06/07/2016 0:00 102534,6
Supplier 1Product 716,21%20/07/2016 0:00 99593,55
Supplier 1Product 811,30%04/02/2014 0:00 73151,8
Supplier 1Product 933,75%21/01/2016 0:00 70003,72
Supplier 1Product 10100,00%19/07/2016 0:00 58502,51
Supplier 1Product 1172,16%13/05/2016 0:00 53824,1

 

By using MAXA function I can find the Last purchase date.

 

What I can't is "the last price" for that date. In this case 2,47.

 

I was investigating about Lookupvalue but this functions seems to have problems when two values are found (my case, two receptions at 06 th of July with different price).

 

"if several rows in your table match your criteria, then VLOOKUP in Excel will only return the first (or last) match. On the contrary, LOOKUPVALUE in DAX may return an error if several rows match your criteria. This will occur if [OutputColumn] does not contain the same value for all matching rows".

 

Source: https://thedataspecialist.wordpress.com/2013/02/16/equivalent-of-vlookup-in-daxpart-i/

 

Please I need your help to find the right expression to give me the "maximum value of price" for the "last purchase date".

 

Regards,

5 REPLIES 5
Ciria
Advocate III
Advocate III

Dears

 

Just after clicking "post" an idea came up

 

I have used this, and it seems it works:

 

CALCULATE(MAXA(Receptions[Unit Price €)]);LASTDATE(Receptions[Reception Date]))

 

Regards,

Dears

 

It seems the solution I found by myself works when you look for a value, this is the "unit price", "last purchase date", "amount", etc.

 

But, what about if want to look for a text value like "Supplier Name"?

 

I cannot use the above formula, it doesn't work

 

Any support?

 

Thanks in advance,Smiley Happy

Dears:

 

Any help??

 

Regards,

Anonymous
Not applicable

Hi @Ciria,

 

You can use below measure to get the supplier name:

lookupSupplierName = lookupvalue('Receptions Summary Table'[Supplier Name],'Receptions Summary Table'[Last Purchase],LASTDATE(VALUES('Receptions Summary Table'[Last Purchase])))

 

 Capture.PNGCapture2.PNG


Regards,
Xiaoxin Sheng

Anonymous
Not applicable

@Ciria Please try below to get the table : 

MAx_Price = CALCULATE(MAXA(Maximum_Price[Price]),LASTDATE(Maximum_Price[Date]))

Measure_1 = LOOKUPVALUE(Maximum_Price[Supplier],Maximum_Price[Price],MAXA(Maximum_Price[Price]))

Count_Rows.png

 

 

Regards

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors