Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello all,
I am trying to pull the Item code based on max quantity. For example, if i filtered on customer ID AA, it should return the item code A3A. Is there a measure i can use to solve this?
Solved! Go to Solution.
Hi @Keithlaf34
Try this, create the measure below
Measure =
var _selectedCustomre= SELECTEDVALUE(CustomerSlicer[Customer ID])
var _maxqty= MAXX(filter(ALL('Table'),'Table'[Customer ID]=_selectedCustomre),'Table'[Quantity])
var _maxItem=MAXX(FILTER(ALL('Table'),'Table'[Customer ID]=_selectedCustomre && 'Table'[Quantity]= _maxqty),'Table'[Item Code])
return IF(ISFILTERED(CustomerSlicer[Customer ID]),_maxItem,"select customer")
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
Hi @Keithlaf34
Try this, create the measure below
Measure =
var _selectedCustomre= SELECTEDVALUE(CustomerSlicer[Customer ID])
var _maxqty= MAXX(filter(ALL('Table'),'Table'[Customer ID]=_selectedCustomre),'Table'[Quantity])
var _maxItem=MAXX(FILTER(ALL('Table'),'Table'[Customer ID]=_selectedCustomre && 'Table'[Quantity]= _maxqty),'Table'[Item Code])
return IF(ISFILTERED(CustomerSlicer[Customer ID]),_maxItem,"select customer")
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
You could use TOPN, e.g.
Top Product =
var currentCustomer = SELECTEDVALUE( 'Table'[Customer ID])
var summaryTable = TOPN( 1, 'Table', 'Table'[Quantity])
return IF( COUNTROWS(summaryTable) = 1, SELECTCOLUMNS( summaryTable, "@val", [Item Code]))This would return blank if there are 2 top products, but if you wanted to be able to display all tied products then you could run CONCATENATEX over the summary table
Hi @Keithlaf34
please try
Code =
CALCULATE (
MAX ( Customers[Item Code] ),
Customers[Quantity] = MAX ( Customers[Quantity] )
)
Code =
VAR MaxQty = MAX ( Customers[Quantity] )
RETURN
CALCULATE (
MAXA ( Customers[Item Code] ),
Customers[Quantity] = MaxQty
)
getting a different error unfortunately. appreciate the help.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 20 | |
| 11 | |
| 10 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 34 | |
| 31 | |
| 19 | |
| 12 | |
| 11 |