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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
AmritaOS
Helper I
Helper I

Return Product Name that has the highest unit price

hello

i am looking to return the name of the product that has the highest unit proce. 

product 1 , price 20

product 2 , price 10

product 3 , price 5

 

so i want to return the product name that has the max unit price = Product 1

 

how do i do this?

thanks!!

Amrita

 

2 ACCEPTED SOLUTIONS
bcdobbs
Community Champion
Community Champion

Try something like this:

VAR MaxPrice = 
	MAX(Table[Price])

VAR ProductNames = 
	CALCULATE (
		CONCATENATEX(
			VALUES(Table[Product]),
			Table[Product],
			", " ),
	Table[Price] = MaxPrice
	)
	
RETURN ProductNames



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

AmritaOS
Helper I
Helper I

i did the below and it worked - nice and simple!

Most Expensive Product = LOOKUPVALUE(Products[ProductName],Products[UnitPrice],MAX(Products[UnitPrice]))

 

View solution in original post

5 REPLIES 5
AmritaOS
Helper I
Helper I

i did the below and it worked - nice and simple!

Most Expensive Product = LOOKUPVALUE(Products[ProductName],Products[UnitPrice],MAX(Products[UnitPrice]))

 

bcdobbs
Community Champion
Community Champion

In your test case that works fine. Just be aware that LOOKUPVALUE will return an error if more than one product has the same max price unless you specify an alternative result. @calerof  solution will return BLANK in such cases. I included CONCATENATEX as it will return a list of all max prices.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
calerof
Impactful Individual
Impactful Individual

Hi @AmritaOS ,

You could also use this code:

Highest Price = 
CALCULATE(
    SELECTEDVALUE(Table_20211202[Product Name]),
    Table_20211202[Unit Price] = MAX(Table_20211202[Unit Price])
)

And get this result:

Test.png

 

Hope it helps.

Regards,

Fernando

bcdobbs
Community Champion
Community Champion

Try something like this:

VAR MaxPrice = 
	MAX(Table[Price])

VAR ProductNames = 
	CALCULATE (
		CONCATENATEX(
			VALUES(Table[Product]),
			Table[Product],
			", " ),
	Table[Price] = MaxPrice
	)
	
RETURN ProductNames



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

thank you yes this is definatelly way better and future proofs the measure! 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.