Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |