get a row label from pivot table

%3CLINGO-SUB%20id%3D%22lingo-sub-1884225%22%20slang%3D%22en-US%22%3Eget%20a%20row%20label%20from%20pivot%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1884225%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20all!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20pivot%20table%20and%20I%20would%20like%20to%20get%20some%20information.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20Example%20the%20green%20sqare.%3C%2FP%3E%3CP%3EWhen%20I%20close%20the%20pivot%20table%20the%20text%20will%20change...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1884225%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1884265%22%20slang%3D%22en-US%22%3ERe%3A%20get%20a%20row%20label%20from%20pivot%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1884265%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F867998%22%20target%3D%22_blank%22%3E%40omdl2020%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhat%20do%20you%20mean%20by%20%22close%20the%20pivot%20table%22%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1885159%22%20slang%3D%22en-US%22%3ERe%3A%20get%20a%20row%20label%20from%20pivot%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1885159%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3BThe%20dropdown%20menu%20in%20the%20pivot%20table.%20In%20the%20example%20from%20Xia%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1885286%22%20slang%3D%22en-US%22%3ERe%3A%20get%20a%20row%20label%20from%20pivot%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1885286%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F867998%22%20target%3D%22_blank%22%3E%40omdl2020%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThat's%20how%20GETPIVOTDATA%20works.%20If%20you%20don't%20want%20that%2C%20it's%20better%20to%20use%20SUMIFS%20based%20on%20the%20source%20data.%20Enter%20A%20and%20B%20in%20M3%20and%20M4.%3C%2FP%3E%0A%3CP%3EThen%20enter%20the%20formula%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DSUMIFS(%24E%242%3A%24E%249%2C%24A%242%3A%24A%249%2CN%241%2C%24C%242%3A%24C%249%2C%24M3%2C%24D%242%3A%24D%249%2C%24M%242)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eand%20copy%20or%20fill%20to%20the%20other%20cells.%20See%20the%20attached%20version.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1885289%22%20slang%3D%22en-US%22%3ERe%3A%20get%20a%20row%20label%20from%20pivot%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1885289%22%20slang%3D%22en-US%22%3EThank%20you%20for%20your%20reply.%3CBR%20%2F%3E%3CBR%20%2F%3EBut%20I%20need%20Xia%20and%20A%20and%20B%20from%20the%20pivot%20and%20now%20you%20typed%20it%20so%20it%20is%20not%20dynamic...%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hi all!

 

I have a pivot table and I would like to get some information.

 

For Example the green sqare.

When I close the pivot table the text will change...

 

 

9 Replies
Highlighted

@omdl2020 

What do you mean by "close the pivot table"?

Highlighted

@Hans Vogelaar The dropdown menu in the pivot table. In the example from Xia

Highlighted

@omdl2020 

That's how GETPIVOTDATA works. If you don't want that, it's better to use SUMIFS based on the source data. Enter A and B in M3 and M4.

Then enter the formula

=SUMIFS($E$2:$E$9,$A$2:$A$9,N$1,$C$2:$C$9,$M3,$D$2:$D$9,$M$2)

and copy or fill to the other cells. See the attached version.

 

Highlighted
Thank you for your reply.

But I need Xia and A and B from the pivot and now you typed it so it is not dynamic...
Highlighted

@omdl2020 

In that case, I'd create a second pivot table with Werkzaam as filter field. See the new version.

Highlighted
Thank you but i don't need this information in a pivot table.
So the question is how to get a row label from pivot table in a cel that is not a pivot table
Highlighted

@omdl2020 

I don't think it's possible to do what you want, but hopefully someone else will prove me wrong.

Highlighted

@omdl2020 

GETPIVOTDATA() doesn't work in such case, it provides data if only it is visible in PivotTable. Alternatively you may work with cube assuming you are at least on Excel 2010, as I remember it's the first which supports data  model.

 

Creating PivotTable add data to data model by checking

image.png

Create PivotTable and after that convert it to cube formulas. Now you may take these formulas and convert it to form you need, for example

image.png

in H3 it could be

 

=CUBEVALUE(
   "ThisWorkbookDataModel",
    CUBEMEMBER("ThisWorkbookDataModel",
         "[Measures].[Sum of Aantal dagen]"
    ),
    CUBEMEMBER("ThisWorkbookDataModel",
       ($G$2,$G3)
    ),
    CUBEMEMBER("ThisWorkbookDataModel",
         "[Range].[Week]." &"[" & TEXT(H$1,"General") & "]"
    )
)

 

and drag it to the right and down.

Remove generated cube formulas you don't need.

 

If in parallel you need PivotTable as well, better to create it using data model

image.png

Filtering of this PivotTable won't affect cube formulas, they use only connection to data model but not another PivotTables created based on it.

Highlighted

@omdl2020 

I am not a great Pivot Table user so I tend to duck out of the PT environment and resort to dynamic arrays.

= UNIQUE(Table1[Medewerker])

If you also wish to filter the headings to omit the rows without content the formula starts to get somewhat overcomplicated.

= LET(
  distinct, UNIQUE(Table1[Medewerker]),
  totaal,  GETPIVOTDATA(
    "Aantal dagen",PivotTable,
    "Medewerker", distinct,
    "Werkzaam",Werzaam),
  FILTER( distinct, ISNUMBER(totaal) ) )

In either case, the table content is of the form

= IFERROR( GETPIVOTDATA(
    "Aantal dagen", PivotTable,
    "Week", Week#,
    "Medewerker", Medewerker#,
    "Werkzaam", Werzaam),
  "-" )

 A combination of INDEX/SMALL/MATCH can be used in place of FILTER.