Forum Discussion
Issue: Row Totals Are Correct, But Column Total is Incorrect in DAX Measure (Must Use Measures)
I have a dynamic pricing model in Power BI that calculates per-quantity charges based on different asset types (Equities, Futures, and Options) and their respective rate tiers.
The measure must be dynamic because users need to test different price points by adjusting the price per quantity through slicers or parameters. This means I cannot use calculated columns or pre-aggregated tables—I must use measures.
What’s Working:
- The row-level values are correct when displaying the results.
- Users can interact with the report and adjust pricing dynamically.
What’s Not Working:
- The column total does not sum correctly when all asset types and contract types are included together.
- If an account has multiple contract types (e.g., both Micro and Standard Futures or both Index and Non-Index Options), the total is incorrect.
- The measure works fine when using page-level filters (e.g., only showing one contract type), but fails when aggregating all contract types together.
- The total only displays correctly when a filter is applied to the visual. Without a filter, the column total does not match the sum of the row totals.
What I Have Tried:
- Using SUMX to iterate through each row.
- Applying CROSSJOIN and SUMMARIZE to structure calculations properly.
- Breaking calculations into separate measures for each contract type (Micro, Standard, Index, Non-Index) and summing them together.
- Using ALLSELECTED and ALLEXCEPT to control total row behavior.
- Trying HASONEVALUE to adjust logic for totals.
Requirement:
✅ The solution must use measures (not calculated columns) because pricing needs to be dynamic.
✅ The column total must correctly sum the row-level values without requiring page-level filters.
✅ The report must work when multiple contract types are selected together (e.g., Micro + Standard).
✅ The solution should be optimized for performance since the dataset is large.
Question:
How can I modify my Dynamic_Per_Quantity_Charge measure so that:
- The column total correctly sums the row totals, even when multiple contract types are included.
- The measure remains fully dynamic, allowing users to test different price points in real time.
- The total works correctly even when no filters are applied to the visual.
- Performance remains optimized for large datasets.
Would greatly appreciate any insights on resolving this.
6 Replies
- kjmts5200Frequent Visitor
Here is my dax
New_Per_Quantity_Charge =SUMX(ADDCOLUMNS(CROSSJOIN(VALUES(bowi_net_trade_revenue[AccountID]),VALUES(bowi_net_trade_revenue[Contract Type]),VALUES('Calendar'[Date])),"CalculatedCharge",VAR CurrentTier = [Dynamic_Tier]VAR ContractType = MAX(bowi_net_trade_revenue[Contract Type])VAR Quantity_Shares = [Quantity-Shares]VAR Quantity_Standard = [Quantity-Standard]VAR Quantity_Micro = [Quantity-Micro]VAR Quantity_Index = [Quantity-Index]VAR Quantity_NonIndex = [Quantity-Non-Index]-- Determine the correct charge based on asset type and tierVAR Per_Quantity_Charge =SWITCH(TRUE(),-- **Equities**CONTAINSSTRING(CurrentTier, "Equities_Tier_1"), MAX(Per_Quantity_Charge_Tier_1_Equities[Per_Quantity_Charge_Tier_1_Equities]),CONTAINSSTRING(CurrentTier, "Equities_Tier_2"), MAX(Per_Quantity_Charge_Tier_2_Equities[Per_Quantity_Charge_Tier_2_Equities]),CONTAINSSTRING(CurrentTier, "Equities_Tier_3"), MAX(Per_Quantity_Charge_Tier_3_Equities[Per_Quantity_Charge_Tier_3_Equities]),CONTAINSSTRING(CurrentTier, "Equities_Tier_4"), MAX(Per_Quantity_Charge_Tier_4_Equities[Per_Quantity_Charge_Tier_4_Equities]),CONTAINSSTRING(CurrentTier, "Equities_Tier_5"), MAX(Per_Quantity_Charge_Tier_5_Equities[Per_Quantity_Charge_Tier_5_Equities]),-- **Futures - Micro**CONTAINSSTRING(CurrentTier, "Futures_Tier_1") && ContractType = "Micro", MAX(Per_Quantity_Charge_Tier_1_Futures_Micro[Per_Quantity_Charge_Tier_1_Futures_Micro]),CONTAINSSTRING(CurrentTier, "Futures_Tier_2") && ContractType = "Micro", MAX(Per_Quantity_Charge_Tier_2_Futures_Micro[Per_Quantity_Charge_Tier_2_Futures_Micro]),CONTAINSSTRING(CurrentTier, "Futures_Tier_3") && ContractType = "Micro", MAX(Per_Quantity_Charge_Tier_3_Futures_Micro[Per_Quantity_Charge_Tier_3_Futures_Micro]),CONTAINSSTRING(CurrentTier, "Futures_Tier_4") && ContractType = "Micro", MAX(Per_Quantity_Charge_Tier_4_Futures_Micro[Per_Quantity_Charge_Tier_4_Futures_Micro]),CONTAINSSTRING(CurrentTier, "Futures_Tier_5") && ContractType = "Micro", MAX(Per_Quantity_Charge_Tier_5_Futures_Micro[Per_Quantity_Charge_Tier_5_Futures_Micro]),-- **Futures - Standard**CONTAINSSTRING(CurrentTier, "Futures_Tier_1") && ContractType = "Standard", MAX(Per_Quantity_Charge_Tier_1_Futures_Standard[Per_Quantity_Charge_Tier_1_Futures_Standard]),CONTAINSSTRING(CurrentTier, "Futures_Tier_2") && ContractType = "Standard", MAX(Per_Quantity_Charge_Tier_2_Futures_Standard[Per_Quantity_Charge_Tier_2_Futures_Standard]),CONTAINSSTRING(CurrentTier, "Futures_Tier_3") && ContractType = "Standard", MAX(Per_Quantity_Charge_Tier_3_Futures_Standard[Per_Quantity_Charge_Tier_3_Futures_Standard]),CONTAINSSTRING(CurrentTier, "Futures_Tier_4") && ContractType = "Standard", MAX(Per_Quantity_Charge_Tier_4_Futures_Standard[Per_Quantity_Charge_Tier_4_Futures_Standard]),CONTAINSSTRING(CurrentTier, "Futures_Tier_5") && ContractType = "Standard", MAX(Per_Quantity_Charge_Tier_5_Futures_Standard[Per_Quantity_Charge_Tier_5_Futures_Standard]),-- **Options - Index**CONTAINSSTRING(CurrentTier, "Options_Tier_1") && ContractType = "Options_Index", MAX(Per_Quantity_Charge_Tier_1_Options_Index[Per_Quantity_Charge_Tier_1_Options_Index]),CONTAINSSTRING(CurrentTier, "Options_Tier_2") && ContractType = "Options_Index", MAX(Per_Quantity_Charge_Tier_2_Options_Index[Per_Quantity_Charge_Tier_2_Options_Index]),CONTAINSSTRING(CurrentTier, "Options_Tier_3") && ContractType = "Options_Index", MAX(Per_Quantity_Charge_Tier_3_Options_Index[Per_Quantity_Charge_Tier_3_Options_Index]),CONTAINSSTRING(CurrentTier, "Options_Tier_4") && ContractType = "Options_Index", MAX(Per_Quantity_Charge_Tier_4_Options_Index[Per_Quantity_Charge_Tier_4_Options_Index]),CONTAINSSTRING(CurrentTier, "Options_Tier_5") && ContractType = "Options_Index", MAX(Per_Quantity_Charge_Tier_5_Options_Index[Per_Quantity_Charge_Tier_5_Options_Index]),-- **Options - Non-Index**CONTAINSSTRING(CurrentTier, "Options_Tier_1") && ContractType = "Options_NonIndex", MAX(Per_Quantity_Charge_Tier_1_Options_NonIndex[Per_Quantity_Charge_Tier_1_Options_NonIndex]),CONTAINSSTRING(CurrentTier, "Options_Tier_2") && ContractType = "Options_NonIndex", MAX(Per_Quantity_Charge_Tier_2_Options_NonIndex[Per_Quantity_Charge_Tier_2_Options_NonIndex]),CONTAINSSTRING(CurrentTier, "Options_Tier_3") && ContractType = "Options_NonIndex", MAX(Per_Quantity_Charge_Tier_3_Options_NonIndex[Per_Quantity_Charge_Tier_3_Options_NonIndex]),CONTAINSSTRING(CurrentTier, "Options_Tier_4") && ContractType = "Options_NonIndex", MAX(Per_Quantity_Charge_Tier_4_Options_NonIndex[Per_Quantity_Charge_Tier_4_Options_NonIndex]),CONTAINSSTRING(CurrentTier, "Options_Tier_5") && ContractType = "Options_NonIndex", MAX(Per_Quantity_Charge_Tier_5_Options_NonIndex[Per_Quantity_Charge_Tier_5_Options_NonIndex]),BLANK())-- Apply Charge ONLY to Relevant Quantity TypeRETURNIF(NOT ISBLANK(Per_Quantity_Charge),Per_Quantity_Charge *SWITCH(TRUE(),CONTAINSSTRING(CurrentTier, "Equities"), Quantity_Shares,CONTAINSSTRING(CurrentTier, "Futures") && ContractType = "Standard", Quantity_Standard,CONTAINSSTRING(CurrentTier, "Futures") && ContractType = "Micro", Quantity_Micro,CONTAINSSTRING(CurrentTier, "Options") && ContractType = "Options_Index", Quantity_Index,CONTAINSSTRING(CurrentTier, "Options") && ContractType = "Options_NonIndex", Quantity_NonIndex,0),0)),[CalculatedCharge] // The expression for SUMX to evaluate for each row)- AnonymousNot applicable
Hi kjmts5200,
DAX doesn’t aggregate totals in matrix visuals the same way it does for individual rows. When calculating totals, it uses a broader filter context and skips row-by-row evaluation, which breaks logic relying on fine-grained granularity—especially with virtual tables like CROSSJOIN.
To fix this, avoid CROSSJOIN and MAX, as they cause context transition issues. Instead, use SUMX over a SUMMARIZE table that matches your row granularity (e.g., AccountID, Contract Type, Date) to ensure consistent and accurate calculation for both rows and totals.
Regards,
Vinay Pabbu
- Greg_DecklerCommunity Champion
kjmts5200 First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e
This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376
Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907
Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8 - AnonymousNot applicable
Hi kjmts5200,
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.Regards,
Vinay Pabbu- AnonymousNot applicable
Hi @kjmts5200,
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.Regards,
Vinay Pabbu- AnonymousNot applicable
Hi @kjmts5200,
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.Regards,
Vinay Pabbu