Using Slicers with Formulas in Excel: Let Users Select Parameters

Jul 18, 2020 • 8 min read

Slicers are a great way to add interactivity to an Excel report. Click a button, choose a sales rep or customer type, and the results change. There is just one problem: slicers do not connect directly to standard Excel formulas.

Natively, slicers work with PivotTables, PivotCharts, tables, and cube functions. The first three do not always give us the flexibility we can achieve with formulas, while cube functions require the Data Model.

Fortunately, a little Excel trickery gives us the best of both worlds. We can use a PivotTable to turn slicer selections into a list of cell values, then use that list as criteria in our formulas.

We will build this up from one slicer with one selection to multiple slicers with multiple selections. Connecting the slicer is the easy part. As the requirements become more advanced, it is our formula skills that do the work.

To work through the examples, download the example workbook.

What You'll Learn

  • Use a filtered PivotTable list to pass slicer selections into standard Excel formulas.
  • Combine SUMIFS results with SUM or SUMPRODUCT to support multiple selections in one slicer.
  • Multiply reverse COUNTIF tests to calculate totals controlled by multiple slicers.
  • Display selected parameters with TEXTJOIN so reports retain their context when printed.

Understand Scalars and Arrays First

Before we connect anything, we need to understand what happens when we give a function several values where we would normally give it just one.

A scalar is a single value. In a formula, a scalar argument is one where Excel normally expects a single value, such as a lookup value or a selection criterion.

Our example data has 26 customer records in rows 2 to 27, with these columns:

  • Column A: Customer
  • Column B: Location
  • Column C: Sales Rep
  • Column D: Customer Type
  • Column E: Value

VLOOKUP with One Value and Several Values

Suppose H7 contains the customer name Hotel. A standard exact-match VLOOKUP is:

=VLOOKUP(H7,A2:E27,5,0)

Hotel is our single lookup value, and the formula returns 85 from the fifth column.

Now suppose H10:H13 contains Hotel, Mike, Romeo, and Victor. Instead of supplying one lookup value, we can supply all four:

=VLOOKUP(H10:H13,A2:E27,5,0)

In a dynamic array version of Excel, the results spill into four cells:

  • Hotel: 85
  • Mike: 105
  • Romeo: 60
  • Victor: -20

We have effectively asked Excel to perform one lookup for each customer in the selection list.

SUMIFS Works the Same Way

With one customer as the criterion, SUMIFS looks like this:

=SUMIFS(E2:E27,A2:A27,H7)

Because each customer name is unique in this data, Hotel again returns 85.

Give SUMIFS four customer criteria instead, and it calculates a separate total for each one:

=SUMIFS(E2:E27,A2:A27,H10:H13)

This produces the same four values as the lookup example. That ability to calculate several totals from a list of criteria is what makes our first slicer formula possible.

COUNTIF and the Reverse COUNTIF Technique

COUNTIF can also accept one criterion or several:

=COUNTIF(A2:A27,H7)
=COUNTIF(A2:A27,H10:H13)

The first formula returns 1 because Hotel appears once. The second returns four counts, one for each customer in H10:H13.

Now for the useful part. Swap the arguments around:

=COUNTIF(H10:H13,A2:A27)

This is what I call a reverse COUNTIF. It is still the normal COUNTIF function, but we are using our short selection list as the range and every customer in the source data as the criteria.

Instead of four results, we get 26 results, one for each source record:

  • 1 means the customer appears in the selection list.
  • 0 means the customer does not appear in the selection list.

Keep that idea in mind. Later, we will use those ones and zeros to decide which rows contribute to a total.

What about older Excel versions? Dynamic array Excel displays these multiple results directly. Traditional Excel can calculate the arrays within an appropriate array formula, even though it does not spill them onto the worksheet. We will use Ctrl + Shift + Enter or SUMPRODUCT where needed.

Connect One Slicer to a Standard Excel Formula

Start on the SUMIFS single slicer worksheet if you are using the example workbook. Our first goal is to select Dave, Donna, or Karen in a Sales Rep slicer and calculate their values by location.

1. Create a PivotTable to Hold the Selection

  1. Select the source data, including the column headers.
  2. Choose Insert > PivotTable.
  3. Select Existing Worksheet and set the destination to N3.
  4. Click OK.
  5. Drag Sales Rep into the Rows area.

The PivotTable now gives us a unique list of sales reps. We do not need a Values field because this PivotTable is not performing our final calculation. Its job is simply to expose the slicer selection in cells.

Remove the grand totals, too:

  1. Right-click inside the PivotTable and choose PivotTable Options.
  2. Open Totals & Filters.
  3. Clear both grand total options and click OK.

2. Add the Sales Rep Slicer

  1. With the PivotTable selected, choose PivotTable Analyze > Insert Slicer.
  2. Select Sales Rep and click OK.
  3. Move the slicer into position. Hold Alt while moving it to snap it to the worksheet grid.

Click a sales rep in the slicer. The PivotTable now displays only that name, with the selected value in N4.

Excel worksheet with a Sales Rep slicer and a filtered PivotTable at the right
The PivotTable exposes the selected sales rep as a cell value our formulas can use.

3. Reference the PivotTable in SUMIFS

If H6 contains Birmingham, enter this formula in I6:

=SUMIFS($E$2:$E$27,$B$2:$B$27,$H6,$C$2:$C$27,$N$4)

The formula adds the values in column E where:

  • The location in column B matches H6.
  • The sales rep in column C matches the selected name in N4.

The source ranges and N4 are fixed with dollar signs. The location reference, $H6, keeps column H fixed but allows the row to change when we copy the formula down.

Fill the formula down alongside the other locations. Selecting a different sales rep now changes the location totals.

That is the connection made. The slicer filters the PivotTable, and the formula reads the PivotTable result.

4. Show the Selected Sales Rep

We can also use N4 in a report heading:

="Sales rep: "&N4

The label updates with the slicer, so the report makes its selection criteria clear.

Allow Multiple Selections in One Slicer

What happens if somebody selects Dave and Donna together?

The PivotTable displays both names, but our formula still refers only to N4. It uses the first name and ignores any additional selections.

There is nothing wrong with the slicer. We have simply given SUMIFS one criterion when we now need to give it a list.

Pass the Entire Selection List to SUMIFS

The three possible sales reps occupy N4:N6 when all are selected. For the multiple-selection example, with Birmingham in H20, use:

=SUMIFS($E$2:$E$27,$B$2:$B$27,$H20,$C$2:$C$27,$N$4:$N$6)

In dynamic array Excel, this returns three results rather than a single total. Each result corresponds to one cell in the selection range.

To combine those results, wrap SUMIFS in SUM:

=SUM(SUMIFS($E$2:$E$27,$B$2:$B$27,$H20,$C$2:$C$27,$N$4:$N$6))

Now Excel calculates the SUMIFS results and adds them together. One selection, two selections, or all three selections feed into the same total.

Copy the formula down for the other locations. If you expect more sales reps in the future, allow enough rows in the referenced selection range to include them.

Make the Formula Work in Traditional Excel

In a version of Excel without dynamic arrays, confirm the SUM formula with Ctrl + Shift + Enter. Excel displays curly braces around the formula to indicate that it is an array formula. Do not type those braces yourself.

Alternatively, replace SUM with SUMPRODUCT:

=SUMPRODUCT(SUMIFS($E$2:$E$27,$B$2:$B$27,$H20,$C$2:$C$27,$N$4:$N$6))

SUMPRODUCT handles arrays natively, so this version avoids the extra keyboard combination.

Display All Selected Names with TEXTJOIN

A direct reference to N4 is no longer enough for our heading either. We need to combine every selected name:

="Sales rep: "&TEXTJOIN(", ",TRUE,$N$4:$N$6)

TEXTJOIN uses a comma and a space between names. The TRUE argument tells it to ignore empty cells, which is useful when the PivotTable displays fewer than three names.

With all three selected, the heading reads Sales rep: Dave, Donna, Karen. Change the selection, and the heading changes with it.

Use Multiple Slicers with Multiple Selections

One slicer is useful, but what if we also want users to choose a customer type?

Our next report needs to calculate values by location while allowing multiple selections for both:

  • Sales Rep: Dave, Donna, or Karen
  • Customer Type: Premium or Standard

If you are following the workbook, move to the SUMIFS multiple criteria slicer worksheet.

Create a Separate PivotTable for Each Selection List

  1. Create the Sales Rep PivotTable at N3 as before, with Sales Rep in Rows and grand totals removed.
  2. Copy the PivotTable with Ctrl + C and paste it into a separate area below using Ctrl + V.
  3. In the copied PivotTable, remove Sales Rep from Rows and replace it with Customer Type.
  4. Insert a Sales Rep slicer from the first PivotTable.
  5. Insert a Customer Type slicer from the second PivotTable.
  6. Position both slicers beside the report.

Each slicer now filters its corresponding PivotTable. For the formulas below, the Sales Rep selection list is N4:N6, and the Customer Type selection list is N11:N12. If you place the second PivotTable elsewhere, adjust those references accordingly.

Excel worksheet with Sales Rep and Customer Type slicers beside two PivotTable lists
Each slicer supplies its own list of selected criteria.

We now have multiple criteria lists, each of which can contain multiple values. Rather than extending the simple SUMIFS pattern, we will build a row-by-row calculation using reverse COUNTIF and Boolean logic.

Build the Multiple-Slicer Formula with Boolean Logic

The aim is straightforward: include a source row only when its location matches, its sales rep is selected, and its customer type is selected.

1. Test the Location

With Birmingham in H7, start in I7 with:

=COUNTIF($H7,$B$2:$B$27)

This checks each source location against H7. The result is an array containing one entry for each source row: 1 for Birmingham, 0 for anywhere else.

2. Test the Selected Sales Reps

Next, check whether each source sales rep appears in the filtered PivotTable list:

=COUNTIF($N$4:$N$6,$C$2:$C$27)

Because the PivotTable contains a unique list of sales reps, this also gives us ones and zeros. A row returns 1 if its sales rep is selected, and 0 otherwise.

Multiply the location and sales rep tests together:

=COUNTIF($H7,$B$2:$B$27)*COUNTIF($N$4:$N$6,$C$2:$C$27)

This works because of some very simple maths:

  • 1 × 1 = 1: Both conditions match.
  • 1 × 0 = 0: Only the location matches.
  • 0 × 1 = 0: Only the sales rep matches.
  • 0 × 0 = 0: Neither condition matches.

Multiplication acts as AND logic. A row survives only when both tests return 1.

For example, when Birmingham is the location and Dave is selected, the ones align with the source rows containing both Birmingham and Dave. In the example data, one such match is the 13th source record, on worksheet row 14.

3. Add the Customer Type Test

Use the same reverse COUNTIF technique for the second selection list:

=COUNTIF($N$11:$N$12,$D$2:$D$27)

Multiply this into the existing calculation:

=COUNTIF($H7,$B$2:$B$27)*COUNTIF($N$4:$N$6,$C$2:$C$27)*COUNTIF($N$11:$N$12,$D$2:$D$27)

Now a row returns 1 only when all three conditions match. Selecting Standard in the Customer Type slicer, for example, removes Premium customer rows from the calculation.

4. Multiply by the Values and Add the Results

Finally, multiply the matching-row indicators by the values in column E and wrap the calculation in SUM:

=SUM(
COUNTIF($H7,$B$2:$B$27)*
COUNTIF($N$4:$N$6,$C$2:$C$27)*
COUNTIF($N$11:$N$12,$D$2:$D$27)*
$E$2:$E$27
)

Rows that meet all the conditions retain their original values because they are multiplied by 1. All other rows become zero. SUM then adds the remaining values.

Copy the formula down for each location. Both slicers now drive the formula results, including combinations of multiple selections in either slicer.

For traditional Excel, confirm the SUM version with Ctrl + Shift + Enter, or use SUMPRODUCT instead:

=SUMPRODUCT(
COUNTIF($H7,$B$2:$B$27)*
COUNTIF($N$4:$N$6,$C$2:$C$27)*
COUNTIF($N$11:$N$12,$D$2:$D$27)*
$E$2:$E$27
)

Make the Report Explain Its Selections

To finish the report, add a label for each slicer selection list:

="Sales rep: "&TEXTJOIN(", ",TRUE,$N$4:$N$6)
="Customer type: "&TEXTJOIN(", ",TRUE,$N$11:$N$12)

These labels do more than tidy up the worksheet. If the report is printed, the selected parameters remain visible alongside the results. There is no need to guess which sales reps or customer types produced the numbers.

The Slicer Connection Stays Simple

The underlying method does not change as the report becomes more advanced: use a slicer to filter a PivotTable list, then reference that list in a formula.

A single selected item can feed directly into SUMIFS. Multiple selections in one slicer can feed into SUMIFS wrapped in SUM or SUMPRODUCT. For multiple selection lists, reverse COUNTIF creates row-level tests that we can multiply together and apply to the source values.

The PivotTables provide the connection. The formulas provide the flexibility.

Share

Excel Off The Grid

I help you reduce repetitive Excel work with practical guides to formulas, Power Query, reporting, and automation.

© 2026 Excel Off The Grid
Powered by Convella