Pivot Table Issues

How to Control Pivot Table Sort Order from a Slicer Selection in WPS Spreadsheets

Camila MilosovichCamila Milosovich Nov 13, 2026 870 views

Question details

The user needs a pivot table to place the first value selected in an Excel slicer at the top and display subsequently selected values below it in the click order.

How to Control Pivot Table Sort Order from a Slicer Selection in WPS Spreadsheets
Product
WPS Spreadsheets
Device & OS
not provided
Scenario
The user is working with a slicer in a pivot table and wants the visible table order to follow the sequence in which slicer buttons are clicked, rather than the default alphabetical or data order.
Observed behavior
A slicer only filters records and does not remember the order in which slicer items were selected, so the pivot table cannot automatically reorder rows according to the click sequence.
Before you start

Make sure your pivot table and slicer already exist in WPS Spreadsheets, and add a unique identifier to the source data if it does not already have one. If you plan to use a macro, open the Developer tab and save a copy of the workbook as a macro-enabled file.

Solution 1Recommended

Record Slicer Selection Order with a VBA Macro and Sort the Pivot Table

Use this method when you need the table order to update automatically according to the exact sequence in which slicer items are clicked.

A slicer cannot natively store click order, so a macro must listen for slicer changes and write a rank to a helper column in the source data.

The pivot table can then sort by that rank to place the first selected value at the top.

1
Open the macro editor

In WPS Spreadsheets, click the Developer tab, then choose Visual Basic or Macros to open the macro editor.

2
Add the selection-order macro

Insert a new module and paste a macro that captures the PivotTable slicer selection event and writes the rank of each selected slicer item to a SortOrder helper column in the source data.

3
Run or attach the macro

Run the macro once or connect it to the slicer change event so it updates the helper column automatically when a slicer button is clicked.

4
Refresh and sort the pivot table

Return to the pivot table, click Refresh, and use Row Label Sort Options to sort by the SortOrder helper field in ascending order.

Record Slicer Selection Order with a VBA Macro and Sort the Pivot Table
Macro availability: Excel VBA code may need small changes for your WPS Spreadsheets version; test on a copy of the workbook first.
WPS Spreadsheets workaround

Control Slicer Selection Sort Order in WPS Spreadsheets

WPS Spreadsheets can accomplish this by adding a rank helper column to the source data and then sorting the pivot table by that rank, so the first selected slicer value appears at the top.

  1. 1. Prepare the source data: Open the workbook in WPS Spreadsheets, confirm the source table has a unique Item column, and add a SortOrder helper column.
  2. 2. Assign ranks from slicer clicks: Use the VBA macro or a priority-table VLOOKUP to write 1, 2, 3 in SortOrder as slicer items are selected or ordered.
  3. 3. Add the helper to the pivot table: Click the pivot table, open Field List, and drag SortOrder into the Values area so it can be used for sorting.
  4. 4. Sort row labels by rank: Right-click a row label in the pivot table, open Sort > More Sort Options, and choose Ascending by the Sum of SortOrder field.
  5. 5. Refresh and verify: Click PivotTable Analyze > Refresh, then click different slicer buttons and confirm the first selected item appears at the top.
Sort pivot rows by a custom rank that reflects the slicer click order instead of the default item order.Works with existing Excel workbooks and keeps .xlsx formatting and formulas intact.Free, lightweight spreadsheet tools with familiar pivot table and slicer features.No need to manually drag slicer items after each selection.Opens and saves .xlsx, .xlsm, and other Microsoft Excel formats without changing the workflow.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my Excel slicer not remember the order I click items?

A slicer is a filter control, not a sort control. It filters the pivot table but does not store click sequence, so you need a helper rank column or a macro.

Can WPS Spreadsheets open an Excel workbook that already has slicers?

Yes. Open the workbook in WPS Spreadsheets, and the slicer remains available; you can refresh and modify the pivot table while keeping the .xlsx file compatible.

How do I sort a pivot table by a helper column in WPS Spreadsheets?

Add the helper column to the Values area, right-click a row label, choose Sort, and sort by the helper field in ascending order.

Does the SORTBY approach work in all WPS Spreadsheets versions?

SORTBY requires a version that supports dynamic array formulas; if your version does not support it, use the priority-table VLOOKUP or macro method.

Can I use a macro to capture slicer selection order?

Yes. Open the Developer tab > Visual Basic, add a module that handles the slicer change event, and write the selected rank to a SortOrder column in the source data.