Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi there
I have been struggling with the Matrix Calculation for years, and SUMX + VALUES seems to be most handy way that can cover most situations. However as you can below it won't help when there are more than 2 layers of context (i.e. LP_ABBR (customer name), MonthDate and ProductLine5 here)... The displayed outcome are obviously wrong... Need your help on it. Thanks!
Hi All,
Firstly ahadkarimi thank you for your solution!
And @yamacha to my understanding,you want to get the error for each product line for that month and then add that up, right?
The matrix can be aggregated for you, you don't need to write your own aggregation function, maybe my data is too simple to reproduce your problem, if you can can you upload some sample data, maybe it will help to solve your problem.
ERROR_LP = ABS(SUM('basic data'[Actual Qty])-SUM('basic data'[FCST Qty]))
I would be extremely proud if I could solve your problem and look forward to hearing from you!
Hope it helps!
Best regards,
Community Support Team_ Tom Shen
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Hi Xingshen
Thanks for the comments, but unfortunately it's not that simple. There is a further layer below the product line that is the UPN (SKU), and I need to calculate the error on these 2 different levels (that's why you see I have to columns for Error).
Hi @yamacha ,
I apologise for not providing you with a suitable solution as I didn't understand you correctly.
If sumx and value may not be able to calculate the value of the difference between the strata correctly, you can use the alexecpt function to add a qualification to determine the stratum you need to calculate
-- ERROR_LP_PL5 =
CALCULATE(
MAXX(
VALUES('Table'[ProductLine5]),
ABS(SUM('Table'[Actual Qty]) - SUM('Table'[FCST Qty]))
),
ALLEXCEPT('Table', 'Table'[LP_ABBR], 'Table'[MonthDate], 'Table'[ProductLine5])
)
-- ERROR_LP_UPN =
CALCULATE(
MAXX(
VALUES('Table'[UPN]),
ABS(SUM('Table'[Actual Qty]) - SUM('Table'[FCST Qty]))
),
ALLEXCEPT('Table', 'Table'[LP_ABBR], 'Table'[MonthDate], 'Table'[ProductLine5],'Table'[UPN])
)
If in doubt, check out the pbix file I uploaded and I'd be honoured if I could help you out!
Best regards,
Community Support Team_ Tom Shen
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Hi Xingshen
Thanks for the warm follow-up. I tried with your codes, and found the issue below
As you were using the naming 'Table' to represent multiple tables, I'm kinda confused on the syntax below. I assume the 3 Tables with column quoted refer to the master tables, then what is the first 'Table'? I do have 2 tables for actual and forecasted demand respectively. Thanks.
ALLEXCEPT('Table', 'Table'[LP_ABBR], 'Table'[MonthDate], 'Table'[ProductLine5])
Hi @yamacha ,
Has your problem been solved after all this time, or has a new problem arisen, if there are any other questions on this issue, feel free to contact me and I'll get back to you as soon as I receive the message.
Hope it helps!
Best regards,
Community Support Team_ Tom Shen
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Hi Xingshen
Sorry for the late response, busy indeed these days.
I kinda locate the root cause (not the aggregation forumula issue): once I apply the 'RemoveEmpty' function that is simply to scope out lines with empty Actual Qty/FCST Qty, the total will become weird (2nd pic below). Just wonder if you have any clue on it? Thanks!
Hi @yamacha ,
The ALLEXCEPT function is used in order to better determine the level at which you need to perform the subtraction to ensure that the correct subtraction is performed. If the ALLEXCEPT function is not included, it is possible that the two measurements will yield the same result according to the context of SUMX, which is in a nutshell to determine the level at which the subtraction should be performed to the Row of the matrix, and the level at which the subtraction should be performed. ALLEXCEPT is used to make a judgement on the Row, depending on what is put in the Row, and is not directly related to the different tables.
I would be honoured if my answer solves your query!
Hope it helps!
Best regards,
Community Support Team_ Tom Shen
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Hi @yamacha, try this SUMMARIZE, if you encounter any issues, let me know.
ERROR_LP_PLS =
SUMX(
SUMMARIZE(
ACTUAL_LP,
LP_ABBR[LP_ABBR],
TIME[MonthDate],
MASTER_PL[ProductLine5],
"ActualQty", SUM(ACTUAL_LP[Actual Qty]),
"ForecastQty", SUM(FCST_LP[FCST Qty])
),
ABS([ActualQty] - [ForecastQty])
)
Did I answer your question? If so, please mark my post as the solution!✔️
Your Kudos are much appreciated! Proud to be a Responsive Resident!
Thanks ahadkarimi
I created two columns (end with Neo) with your codes as below. As only 'ACTUAL_LP' is summarized in your code so it will miss the lines w/o actual demand but still with forecast, and ultimately underestimate the error.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.