Forum Discussion
Anonymous
5 years agoNot applicable
Rank orders by value with multiple lines per order
Hello community, hope you can help me out ... I've been trying to create a ranking of sales orders where some of them can have multiple line in the fact table since a given order can contain mul...
- 5 years ago
Anonymous
You can try this one. I suspect it's now doing what you wanted...
Sales BG2 = var CurrentlyVisibleGroups = DISTINCT( 'Order Groups'[Group] ) var CurrentlyVisibleOrders = DISTINCT( SalesOrders[OrderNo] ) var OrdersInCurrentlyVisibleGroups = CALCULATETABLE( var AllOrders = DISTINCT( SalesOrders[OrderNo] ) return FILTER( CurrentlyVisibleOrders, var OrderRank = RANKX( AllOrders, [Sales],, DESC ) var OrderGroup = MAXX( FILTER( 'Order Groups', 'Order Groups'[Min] < OrderRank && OrderRank <= 'Order Groups'[Max] ), 'Order Groups'[Group] ) return OrderGroup in CurrentlyVisibleGroups ), ALLEXCEPT( SalesOrders, 'Date' ), // This directive should let you only rank // against orders that are relative to // all the visible products, visible // somewhere in your visual, not necessarily // just in the cell being evaluated. ALLSELECTED( 'Products' ) ) var Result = CALCULATE( [Sales], OrdersInCurrentlyVisibleGroups ) return ResultBear in mind that 'Products' must be a dimension connected to your fact table 'SalesOrders'. And you should never slice in the UI by the columns of your fact tables. Only via dimensions. If you don't follow this rule... you'll be in trouble sooner or later. I tell you today.
daxer-almighty
Solution Sage
5 years agoGood you got it working exactly as you wanted. Sorry I was not able to address this problem immediately but I did not fully understand how this measure should behave in all possible contexts.
Anonymous
5 years agoNot applicable
You did great and put me on the right direction .. thanks for your help.