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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Syndicate_Admin
Administrator
Administrator

Total erroneous table

Good afternoon, I need to calculate a weighted cost per item and wanting to do it the total that shows me the table is wrong.

I have the following measurement:

ZZZZZ % cost variation WEIGHTED WITH FILTER =
WHERE CostoListaASerComparada = if([Units Billed]>0,CALCULATE(SUMX(FACT_hojaDeCostos, FACT_hojaDeCostos[Unit cost] * FACT_hojaDeCostos[units]),
FACT_hojaDeCostos[LIST NAME] =SELECTEDVALUE(AuxiliarListasDeCostosPeriodoAComparar[NUMBER]),
'FACT_Facturacion'[Type of item]<>"C2.5 - SHIPPING EXPENSES"))

WHERE CostoListaAnterior = if([Units Billed]>0,CALCULATE(SUMX(FACT_hojaDeCostos, FACT_hojaDeCostos[Unit cost] * FACT_hojaDeCostos[units]),
FACT_hojaDeCostos[LIST NAME] =SELECTEDVALUE(AuxiliarListasAnterior[NUMBER]),
'FACT_Facturacion'[Type of item]<>"C2.5 - SHIPPING EXPENSES"))

RETURN
CALCULATE(DIVIDE(CostoListaASerComparada - CostoListaAnterior, CostoListaAnterior, BLANK()),
FILTER(DIM_Articulos, [Cost ready to be compared] > 0 && [Cost list above] >0))
The result it shows me is as follows:
flitvak_0-1696006035418.png

In this example, the box should show 7.26%

If I change the "billed units", the total in that column is not updated, it is fixed at 7.21%.

Thanks in advance for the help!!

Best regards

1 REPLY 1
123abc
Community Champion
Community Champion

looks like you're working with Power BI and trying to calculate a weighted cost per item, but you're encountering an issue where the total displayed in the table is not updating as expected when you change the "billed units." The total remains fixed at 7.21% when it should be 7.26%.

This issue could be related to the way the measures are calculated and the interaction with the filter context. It's possible that the calculation for the total is not considering the changes in "billed units." To address this issue, you can try the following steps:

  1. Check Measure Dependencies: Ensure that the measure you are using for "billed units" is correctly defined and that it responds to changes in filters or slicers that may affect it.

  2. Review Filter Context: Review the filter context in your report to make sure there are no conflicting filters or slicers that might be causing the total to remain fixed.

  3. Evaluate Measure Logic: Double-check the logic of your measures CostoListaASerComparada and CostoListaAnterior. Verify that they correctly respond to changes in "billed units."

  4. Use Variables: Consider using variables to break down your measures into smaller, more understandable parts. This can help with debugging and understanding the behavior of your measures.

  5. Check Data Model Relationships: Verify that the relationships between your tables are set up correctly. Incorrect relationships can lead to unexpected results in calculations.

  6. Test with Different Data: Sometimes, the issue might be data-specific. Try applying your measures to different data points to see if the problem persists.

  7. Clear Filters: Sometimes, cached filter values can cause unexpected behavior. Try clearing all filters and slicers in your report to see if the total updates correctly.

  8. Check for Circular Dependencies: Ensure that there are no circular dependencies in your measures that might be causing unexpected behavior.

Without access to your complete Power BI project and dataset, it's challenging to pinpoint the exact issue. However, by following these steps and carefully reviewing your measures and filter context, you should be able to identify and resolve the problem with the total not updating as expected. Additionally, using variables for intermediate results can make your measures more transparent and easier to debug.

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.