How to capture the "group" value in a Pivot Table?

LHumberto

New member
Joined
Jul 20, 2023
Messages
3
Reaction score
0
Points
1
Excel Version(s)
Excel 365
I've been searching around but can't find a way to do this. Probably simple, but one of those that get me stuck...

I have a simple pivot with three columns. RoomID, IP-Address, Count of IP Address (indicates how many times that IP was used during a given date range)

On another tab, i have a list of people and the IP addresses that they have used during that same data range. I then use a xlookup to list by whom the IP was used, and Filter (with Transpose) to list all dates a given individual used an IP address. Because the same IP might appear in different rooms Filter is returning more than it should, as it is capturing the info from all rooms.

Note: using Excel 365, Classic PivotTable layout. Values below are just samples, not my real data.

Pivot (in orange below) is based on "Table 1"
"Who used the IP" uses the IP in a XLOOKUP (simple refence, e.g. "B2") to look on "Table 2"
If someone used the IP, that same IP (again simple reference to that same cell, "B2"), is used with Transpose/Filter to "look" back in "Table 1" and list when the IP was used (When Used column).

The problem is for Mary / IP 1.1.1.1 Transpose/ Filter is listing four dates, as it is capturing info from rooms 00001 & 00002. Two instance from room 00001 and two instances from room 00002.

NOTE: I understand that the dates listed are not the dates Mary used the IP. That info is not present on the users table (Table 2). Those are just the dates the IP was used. But I still need to filter for just the dates the IP was used in that room.

What I (think I) need is to identify which RoomID is associated with that IP (Mary's example, 00001 or 00002) and use that info as a primary Filter. I thought it should be simple to refence the RoomID column / group based on the current row, but I'm failing miserably. GETPIVOTDATA ain't my friend.

There might be a million other ways to do this (and thousands of them better), but my real question is:

Is it possible to make a refence to the Group RoomID (or any other "non-calculated" fields) in a pivot table?

Any pointers are greatly appreciated.


Room IDIPNo of Times IP Used Who Used the IPWhen Used
000011.1.1.12Mary03/10/202104/08/202107/15/202103/02/2022
2.2.2.22Mike01/30/202004/20/2020
3.3.3.35NoN/A
000021.1.1.12Mary03/10/202104/08/202107/15/202103/02/2022
4.4.4.42Paul05/23/201906/25/2019
6.6.6.63No
000032.2.2.21Mike01/30/202004/20/2020
7.7.7.73Steve03/22/202004/06/202010/11/2021
 
It would be much simpler to simply set that field to repeat item labels. Then the room ids will appear in every cell and can be referred to normally.
 
Would a presentation like the following work for you?
Count of ValueColumn Labels
Row Labels
5/23/2019​
6/25/2019​
1/30/2020​
3/22/2020​
4/6/2020​
4/20/2020​
3/10/2021​
4/8/2021​
7/15/2021​
10/11/2021​
3/2/2022​
(blank)
Mary
1
1.1.1.1
1​
1​
1​
1​
2
1.1.1.1
1​
1​
1​
1​
Mike
1
2.2.2.2
1​
1​
3
2.2.2.2
1​
1​
No
1
3.3.3.3
Paul
2
4.4.4.4
1​
1​
Steve
3
7.7.7.7
1​
1​
1​
 

Attachments

  • PQ and PT.xlsx
    22.4 KB · Views: 1
It would be much simpler to simply set that field to repeat item labels. Then the room ids will appear in every cell and can be referred to normally.
Thank you, JP.

I was trying to avoid the label repetition. But it is certainly a possible approach.

I still would like to know how to reference the item labels, though.
 
I'd strongly recommend exploring getting the 2 tables either:
(1) into the data model and linking them (and perhaps creating some measures) then creating a Power Pivot table from that
and/or:
(2) bringing the two tables into the Power Query part of Get & Transform Data and doing some joins therein and either outputting the results directly to a pivot table or to a plain table designed to show what you want.

Whichever of these you use you won't have to think about any formula/references/GETPIVOTDATA/changing ranges that those formulae will need to cover; all you'll need to do when the source data in either or both th tables change is to refresh the table/pivot table.

To that end, could you attach a workbook with (mockups?) of the 2 tables and a small example of the ultimate output you want? I (we?) could then have a go at doing that. No pictures please, and make sure that the data in the two tables are relevant to each other!
 
Thank you, P45Cal.

I do appreciate the input. And I agree that having the data prepared from a relational point of view is most likely better. As I mentioned, there are certainly many different ways to approach this issue.

But my question - more out of curiosity than anything else at this point - remais: is there a way to reference the group columns of a pivot?

I still have not found a way to do that consistently (or without using label repetition, as JoePublic suggested).
 
Might be helpful if we actually saw the source tables. Attach them as it is difficult to work with pictures. Also mock up what you want the end result to look like based upon your sample data.
 
Back
Top