CALCULATE trouble

Misca

Well-known Member
Joined
Aug 12, 2009
Messages
1,760
Office Version
  1. 365
Platform
  1. Windows
Here's my basic Power Pivot data model:


The Sales table has basic transactions data: CustomerID, Product ID, Sales Amount etc. and is connected to the Products -table via Product ID and Customers table with the Customer ID. These tables are connected to the CustomerGroups and ProductGroups tables with GroupIDs.


How do I write a CALCULATE -measure that tells me the NetSales of each ProductGroup for each CustomerGroup even when the pivot table is showing the ProductIDs and CustomerIDs (ie. just the subtotals but for each row)? All the CALCULATE examples seem to have either static values or the SAMEPERIODLASTYEAR-function as the filter values but I'd just need the "level up" values.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi there,

Just focussing on Products first, this is what I think you want to do - does this sound correct ?
"For Products currently visible in the Sales table, calculate the total sales for all Products in the corresponding ProductGroups (with filters other than Products table left unchanged)."

One measure to achieve this would be (I'm assuming Sales[Net Sales] is a column):

Code:
=
CALCULATE (
    SUM ( Sales[Net Sales] ),
    ALL ( Products ),
    SUMMARIZE ( Sales, ProductGroups[GroupID] )
)

A similar pattern would apply for Customers.

To "level up" Products/Customers simultaneously:
Code:
=
CALCULATE (
    SUM ( Sales[Net Sales] ),
    ALL ( Products ),
    ALL ( Customers ),
    SUMMARIZE ( Sales, ProductGroups[GroupID], CustomerGroups[GroupID] )
)

Do these behave as expected in the pivot table you were talking about?
 
Upvote 0
Thank you!

You nailed it: The second formula was just what I was looking for.
 
Upvote 0

Forum statistics

Threads
1,224,144
Messages
6,176,647
Members
452,739
Latest member
SCEducator

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top