Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
rcb0325
Helper I
Helper I

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 1
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.