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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Not quite understanding Totals In Matrices

Hello my wonderful Power BI Community,

I've run into a bit of an issue I'm hoping you all can share some light on. I've looked everywhere but have failed to find anything that is remotely successful.

I'm currently working on a pricing report. The report utilizes a singular fact table of invoices stored in our SQL database which is queried by PBI twice for different results. The first query is called "Base Period" which is anything with an invoice date < January 01 of current year. The other table is called "Current Period" which is anything >= January 01 of current year. I then join these two tables to a bunch of Lookup tables like customers, items, etc. on their associated keys to get various fields. For example, LU Customer joins to both base period and current period on Customer_Key. LU Item joins on Item_Key, etc. Notably I have a fiscal calendar table joined ONLY to the current period table since I want people to be able to slice invoices in the current year by period number, but still see the average price of the base period as a full year calculation. See structure below:

NickAdmin_1-1689798956998.png
I've then created a matrix with Company, Customer, Product Category, and Item Code in the rows. I've then created a bunch of measures to calculate various fields. I'll provide the general idea along with the measure text in red or a screenshot. Further below is a screenshot of the created matrix so you can follow along.
- Average selling price (ASP) in the base period --> Average Selling Price Base Period = average('Base Period'[LocalUnitPrice])

- Average selling price (ASP) in the current period --> Average Selling Price Current Period = average('Current Period'[LocalUnitPrice])
- Price Traction P1 is the first part of the price traction $ equation. It takes the Current Period ASP and subtracts the base period ASP --> 
Price Traction P1 = [Average Selling Price Current Period] - [Average Selling Price Base Period]

- Total quantity is simply the sum of the quantity invoiced from the current period --> Total Quantity = sum('Current Period'[QuantityInvoiced])
 - Price traction $ is the Price Traction P1 multiplied by the total quantity. I've thrown in an IF to make sure that the price traction $ is 0 if either of the ASPs are blank (code in sceenshot below). You'll see further down in the screenshot of the matrix that at the item code level (1901x, 894520, etc.), this calculates correctly. However, the totals need to be the sum of these values rather than the total line P1 * total quantity. This is where the price traction fix below comes into play.
 NickAdmin_2-1689799471401.png

Price Traction Fix is my culmination of hours of research and trying all kinds of things, however it still doesn't work. The equation simply does a sumx based on my LU_Item[Item Code]  and the price traction $ measure (see code below). This was ripped straight from an article I read and has gotten me closest to what I was trying to achieve.

 NickAdmin_3-1689799645449.png
Now the problem arises when you look at the bottom screenshot:
NickAdmin_4-1689799722269.png

We can see the faulty Price Traction $ not doing what I want it to do. The price traction fix however seems to fix it until i go to the upper most total where I'm $246.53 off. If I sum 1901x and 894520 for each customer (Grainger and Airgas) I get the correct amounts, but then those amounts don't sum correctly to the company level at the top.

The only other filters i have applied are:

A base period year which limits the base period table to only show me the prices I want to compare to
A customer filter to limit the data I'm seeing in my visual
A company filter to limit the data I'm seeing in my visual


I'd appreciate any help anyone is willing to give! Thank you for time and energy! Have a blessed day.

Sincerely,
Nick
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Solved the issue after realizing how the data was interacting with my architecture. I needed to change the fix measure to this:

NickAdmin_0-1689864181659.png


The key to figuring this out was to understand that if you put a fact table in the table part of the summarize function, you can use columns from all tables connected to it to summarize on. I thought I couldn't use summarize because I needed to choose the table that the columns i needed were actually in which was impossible because I had two columns in separate tables.

I hope this helps someone else!

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Solved the issue after realizing how the data was interacting with my architecture. I needed to change the fix measure to this:

NickAdmin_0-1689864181659.png


The key to figuring this out was to understand that if you put a fact table in the table part of the summarize function, you can use columns from all tables connected to it to summarize on. I thought I couldn't use summarize because I needed to choose the table that the columns i needed were actually in which was impossible because I had two columns in separate tables.

I hope this helps someone else!

 

Anonymous
Not applicable

So I've figured out the issue. When SumX'ing by item, the values are correct. However, when customer is added, it breaks. It breaks because customers can have different pricing structures which means that their ASPs will be higher or lower which means the Price Traction P1 will be larger or smaller leading to bigger/smaller numbers which don't sum correctly.

I now need to figure out how to sumx with multiple columns to try and get it to sumx based on a combination of Customer Group & item code

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.