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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
windylee
Frequent Visitor

How to show top 1 [Item] with the highest [Price] per [Category] when a slicer [Status] is applied?

I want to display the data using "Table" visual to show the Top 1 [Item] with the highest [Price] per [Category] when a slicer [Status] is applied.

 

Here is my data source table:

CategoryItemPrice $Status
SnacksPeanuts10Active
SnacksChips20Inactive
SnacksCandy15Pending
DrinksCoke30Active
DrinksCoffee25Inactive
DrinksTea10Inactive
FruitsApple10Inactive
FruitsBanana15Active
FruitsOrange20Pending
FruitsPeach25Pending

 

I want the "Top 1" column can be updated when the slicer is filtered by different values. For example:

windylee_0-1740601804262.png

 

 

I tried to create a measure with the below code but it remains unchanged (it will not update according to different status)

 

 

 

_Measure = 
var _max = MAXX(FILTER(ALL('Sheet1'),[Category]=MAX('Sheet1'[Category])),[Price]) 
return CALCULATE(MAX('Sheet1'[Item]),FILTER(ALL('Sheet1'),[Category]=MAX('Sheet1'[Category]) &&[Price]=_max))

 

 

 

  

Please advise. Thank you very much!

1 ACCEPTED SOLUTION
vicky_
Super User
Super User

You will need to add a calculate parameter to get the status to filter

Something like the following:

Measure = 
var selectedStatus = ALLSELECTED('Sheet 1'[Status])
var maxPrices = CALCULATE(MAX('Sheet 1'[Price $]), 'Sheet 1'[Status] in selectedStatus, REMOVEFILTERS('Sheet 1'[Item], 'Sheet 1'[Price $]))
var maxItem =  CALCULATE(MAX('Sheet 1'[Item]), 'Sheet 1'[Price $] = maxPrices)
RETURN maxItem

Here's a good guide to what the ALLSELECTED does - https://www.sqlbi.com/articles/introducing-allselected-in-dax/

 

View solution in original post

2 REPLIES 2
vicky_
Super User
Super User

You will need to add a calculate parameter to get the status to filter

Something like the following:

Measure = 
var selectedStatus = ALLSELECTED('Sheet 1'[Status])
var maxPrices = CALCULATE(MAX('Sheet 1'[Price $]), 'Sheet 1'[Status] in selectedStatus, REMOVEFILTERS('Sheet 1'[Item], 'Sheet 1'[Price $]))
var maxItem =  CALCULATE(MAX('Sheet 1'[Item]), 'Sheet 1'[Price $] = maxPrices)
RETURN maxItem

Here's a good guide to what the ALLSELECTED does - https://www.sqlbi.com/articles/introducing-allselected-in-dax/

 

Thank you so much for your help!

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.