I'm struggling to figure out the correct Excel data model relationship technique to link a slicer to a pivot table in a two-step process.
Here is my simple Excel file to download.
There are three fields in my example data: Person, Activity, and Cost. I want a way for users to pick an Activity (or multiple Activities) in the Activity slicer, and then show the full Cost and Activity data for any Person who does that Activity. Here is a screenshot of the data table (1.), and its full pivot table (2.). The output I desire is mocked up in (3.). It's basically a subset of (2.). The complication is that I want to show the full record (ie all Activities) for the Person, not just the Activity selected by the user in the slicer. So there's a relationship from Slicer Activity -> Person -> All Activities per person/
Screenshot of data and desired outcome
I can can easily break the process down into some simple joins and relationships, but I'm unsure how to implement the below in Power Pivot or Power Query. It must update the final table (Step 4) whenever the slicer is updated. I'm just not sure how to bridge from the Activity slicer to the Person table, and then from the Person table back to the source Data.
screenshot of data model stages
Can this be done simply in Power Pivot?
You are going to need to use the Data Model in Excel, with a Measure, to achieve this. Here is an overview of the steps, then followed by the detail.
Here are the steps:
1. Load table into PowerQuery
Table 1
and rename it toActivity
.Activity
(again on the left) and selectReference
. This will create a new query (table) based on the first.Activity Slicer
.Activity Slicer
, right-click on theActivity
column header and selectRemove other columns
.Remove Duplicates
.Activity
(the same as in the spreadsheet); 2.Activity Slicer
- single columnActivity
with distinct values.Close & Load
and selectClose & Load To...
Import Data
window, selectOnly Create Connection
and at the bottom select (check)Add this data to the Data Model
.2. Create measure in the Data Model
Manage
(first one, with Data Model underneath it).Activity
tab, and then select any cell in the Calculation Area. If Calculation Area isn't visible, then select it in the ribbon.That's it - no relationships needed. Close the Power Pivot window and return to main Excel.
3. Create/add Pivot and Slicer
From Data Model
.Insert Slicer
. Select theAll
tab and you should see the tables from the Data Model. SelectActivity Slicer > Activity
That's it - test!