Forum Discussion

Lawrence_Lam_320's avatar
Lawrence_Lam_320
Copper Contributor
May 18, 2026

Slicer

Hi Expertises, 

Need your help again. I have pivot table as below. I need to capture the Product A sales amount under the following scenarios.

  1. Filter. Select any one country in slicer
  2. NO Filter. Select all country

My problem is when I add formula in text box like =B2, under scenario 1, the answer is correct no matter I select which country in slicer. However, for scenario 2, when i did not use filter, the total of Product A Sales amount should refer to B6 instead of B2. So, i got incorrect answer. 

May i ask your advice in this case? Thanks a lot

 

Regards
Lawrence

CountryProduct A SalesProduct B Sales
AU10040

JP

8060
HK6080
KR40100
Total280280

2 Replies

  • NikolinoDE's avatar
    NikolinoDE
    Platinum Contributor

    Use GETPIVOTDATA...

    This function references PivotTable values by their labels, not by cell coordinates — so it works regardless of filter state.

    =GETPIVOTDATA("Product A Sales", $A$1)

    • "Product A Sales" – the value field name
    • $A$1 – any cell inside your PivotTable (e.g., top-left corner)

    Important: This returns the filtered total automatically.

    • If one country is selected → shows that country’s Product A Sales
    • If all countries are selected → shows Grand Total for Product A Sales

     

    My answers are voluntary and without guarantee!

     

    Hope this will help you.

  • Olufemi7's avatar
    Olufemi7
    Steel Contributor

    Hello Lawrence_Lam_320​,

    The issue is happening because =B2 is a fixed cell reference, while the PivotTable layout changes depending on the slicer selection.

    Instead, use GETPIVOTDATA.

    Example:

    =GETPIVOTDATA("Product A Sales",$A$1)

    Where $A$1 is any cell inside the PivotTable.

    This will return the Product A Sales value for the selected Country when a slicer filter is applied, and the Total Product A Sales when all Countries are selected.

    You can also type = and click the PivotTable value cell directly. Excel will automatically generate the GETPIVOTDATA formula for you.