Forum Discussion

rcb0325's avatar
rcb0325
Helper I
2 years ago

Dreaded Incorrect Measure Totals....

I have been plagued by the infamous incorrect measure total problem, however, this time I can not find a way to resolve it. Below is a picture of the table, and then the measure formulas: 

 

ItemDescInvoiced QtyInvoiced Qty (Incorrect Site)

Invoiced Rank

Incorrect

TOPN Incorrect Qty SwitchNEW Incorrect Invoiced Qty
MJ,ACC,BAG,6,TRANSITION,3/4X31/2,L/GLD76174520761761
BEND,12,MJ,45,C153,CL17217362117211721
BEND,6,MJ,90,C153,CL11717312211711171
GLAND,6,MJ,C153,TC13307052313301330
FLANGE,COMP,4,C110,FOR,DI,BARE-ND64064024640640
BOX,VALVE,6850,562S,GI,ASSY,16T,24B73163825731731
MJ,ACC,PACK,8,C1531304633266331304
BEND,12,MJ,45,C153,CL-ND2560623276232560
MJ,ACC,PACK,16,LESS,GLAND,3/4X41/2,B/N97259628596972
MJ,ACC,PACK,12,LESS,GLAND,3/4X4,B/N1275554295541275
MJ,ACC,PACK,6,C1531063532305321063

 

 

[Invoiced Qty] = Sum(InvoicedQuantity)

[Invoiced Qty (Incorrect Site)] =
CALCULATE( [Invoiced Qty],
FILTER('fact SalesInvoiceView', RELATED('dim InventoryDimensionView'[InventSiteCode]) <> RELATED('Sell To Customer'[SellToCustomerCustomerSite])),
FILTER('fact SalesInvoiceView', RELATED('dim SalesInvoiceView'[DeliveryStateCode]) = RELATED('Sell To Customer'[SellToCustomerPrimaryStateCode]))

[Invoiced_Rank_Incorrect] =
VAR fx = RANKX( ALLSELECTED('dim ItemView'), [Invoiced Qty (Incorrect Site)])
RETURN
IF( ISINSCOPE('dim ItemView'[ItemDesc]), fx)
 
[TOPN Incorrect Qty Switch] =
VAR ranks = IF( ISINSCOPE('dim ItemView'[ItemDesc]), RANKX( ALLSELECTED('dim ItemView'), [Invoiced Qty (Incorrect Site)]))
VAR result = IF( ranks <= 25, SUM('fact SalesInvoiceView'[InvoicedQuantity]), [Invoiced Qty (Incorrect Site)])
RETURN
result
 
[NEW Incorrect Invoiced Qty] =
SUMXVALUES( 'dim ItemView'[ItemDesc]), IF( [Incorrect Qty Switch] > 0, [Incorrect Qty Switch])



What I am trying to do, is rank the [Invoiced Qty (Incorrect Site)] ascending. Then, use the [TOPN Incorrect Qty Switch] to look at the top 25 items, and return the [Invoiced Qty], and return the [Invoiced Qty (Incorrect Site)] value for any rank > 25, with the correct summation. 

 

Currently, the [TOPN Incorrect Qty Switch] has the correct values, but incorrect total, and the [New Incorrect Invoiced Qty] has the incorrect values (all showing [Invoiced Qty]), but the correct sum (this measure was created to try and get the [TOPN Incorrect Qty Switch] to sum correctly). 

 

Note: The [ItemDesc] are in a separate table, related to the current table by Dim_Keys
Note: The yellow line in the picture is the 25th ranked item, and where the result measure should switch columns from [Invoiced Qty] to [Invoiced Qty (Incorrect Site)]

 

Please help! I have exhausted all option. 

1 Reply