DAX Expression to link Excel pivot table to a second table based on slicer filter values

49 Views Asked by At

I am trying to link two pivot tables using DAX, without setting up a relationship first, with rows respecting a user's slicer input. I believe from a previous answer to a different question that DAX can do this easily, but I lack the expertise in DAX and PowerPivot Measures.

I have uploaded my sample data here https://github.com/johntdata/Share/raw/master/SampleDataPivotJoin.xlsx. I don't yet have a high enough reputation to post a screenshot, but my data is pretty simple. Table1 looks like this:

┌──────────┬───────┬─────────────┐
│ Activity │ Group │ Staff Count │
├──────────┼───────┼─────────────┤
│ A1       │ A     │           3 │
│ A2       │ A     │           7 │
│ A3       │ A     │          10 │
│ B1       │ B     │           8 │
│ B2       │ B     │           9 │
│ B3       │ B     │           6 │
│ B4       │ B     │           8 │
│ C1       │ C     │          10 │
│ C2       │ C     │           2 │

And Table2 looks like this:

┌──────────┬───────┬──────────┬────────┐
│ Activity │ Group │ Category │ Income │
├──────────┼───────┼──────────┼────────┤
│ A1       │ A     │ Apple    │     15 │
│ A1       │ A     │ Pear     │      9 │
│ A1       │ A     │ Banana   │     27 │
│ A2       │ A     │ Apple    │      3 │
│ A2       │ A     │ Pear     │     47 │
│ A2       │ A     │ Banana   │     54 │
│ A3       │ A     │ Apple    │     41 │
│ A3       │ A     │ Pear     │     10 │

With a slicer on Group, I want to 'combine' the data on the Activity field in order to see sum of Staff Count from Table1 along with the % of Income types from Table2 (with %s expressed as a total of the row). The combined result might look like this:

┌────────────┬────────────────────┬───────┬────────┬──────┐
│ Row Labels │ Sum of Staff Count │ Apple │ Banana │ Pear │
├────────────┼────────────────────┼───────┼────────┼──────┤
│ A1         │                  3 │ 29%   │ 53%    │ 18%  │
│ A2         │                  7 │ 3%    │ 52%    │ 45%  │
│ A3         │                 10 │ 71%   │ 12%    │ 17%  │
│ B1         │                  8 │ 46%   │ 24%    │ 30%  │
│ B2         │                  9 │ 14%   │ 81%    │ 5%   │
│ B3         │                  6 │ 9%    │ 46%    │ 45%  │
│ B4         │                  8 │ 8%    │ 40%    │ 52%  │
│ C1         │                 10 │ 18%   │ 27%    │ 55%  │
└────────────┴────────────────────┴───────┴────────┴──────┘

It would be excessively cumbersome to wrangle my input data into a single table, so I'm hoping to use DAX to join the two tables whilst respecting a slicer on Group from Table1.

I want the user to be able to select one or more Groups using a slicer button. What DAX measure will allow me to do this please? The example above is generic, but the principle will be really useful for lots of my projects.

0

There are 0 best solutions below