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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Kfausch
Helper II
Helper II

Table Totals Incorrect

Hello,

 

I am struggling with a tables totals. I am not sure the correct way to calculate this so both the line and total values are correct.

 

I have two tables; 'Item Ledger' which stores the cost and 'Capacity Ledger' which stores the waste detail.

 

I am trying to correctly determine the cost of scrap values when they are categorized as "Damages" or "Overages". To do that I am summing the cost of the entire amount [Cost Amount Actual] and dividing it by the total number of units to get a Unit Cost. From there I am just multiplying the two numbers together to get the total cost of waste/scrap.

 

 

Waste $ = 
    VAR scrap = CALCULATE(SUM('Capacity Ledger'[Scrap_Quantity]),'Capacity Ledger'[Scrap_Code] = "Damages" || 'Capacity Ledger'[Scrap_Code] = "Overages")
    VAR unitCost = DIVIDE(SUM('Item Ledger'[Cost Amount Actual]), CALCULATE(SUM('Item Ledger'[Quantity]),'Item Ledger'[Entry_Type] = "Output"))
    
    RETURN ROUND((scrap*unitCost),2)

 

 

Kfausch_0-1661268625991.png


My problem is that when it totals, it is using the average Unit Cost rather than summing each row indepentantly. The total for Waste $ should be 175.86, but I am actually getting 174.94.

I am thinking I need to use SUMX in some fasion, but I am not sure what the correct implementation of this would be. The few things I tried did not work as expected. Does anyone know what I could do differently?

Thanks for reading!

Kevin

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You could rename your current measure to something like Waste Line Item then create a measure like

Waste $ =
IF (
    ISINSCOPE ( 'Table'[No] ),
    [Waste Line Item],
    SUMX (
        ADDCOLUMNS (
            SUMMARIZE ( 'Table', 'Date'[Date], 'Table'[No] ),
            "@waste", [Waste Line Item]
        ),
        [@waste]
    )
)

where the columns in the SUMMARIZE are the same columns from the left hand side of your table visual.

View solution in original post

1 REPLY 1
johnt75
Super User
Super User

You could rename your current measure to something like Waste Line Item then create a measure like

Waste $ =
IF (
    ISINSCOPE ( 'Table'[No] ),
    [Waste Line Item],
    SUMX (
        ADDCOLUMNS (
            SUMMARIZE ( 'Table', 'Date'[Date], 'Table'[No] ),
            "@waste", [Waste Line Item]
        ),
        [@waste]
    )
)

where the columns in the SUMMARIZE are the same columns from the left hand side of your table visual.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.