Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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.
User | Count |
---|---|
54 | |
22 | |
19 | |
16 | |
11 |
User | Count |
---|---|
82 | |
55 | |
40 | |
20 | |
12 |