Compare Two Dynamic Segmentation Groups in Excel Power Pivot
Question details
Create two independently selectable groups from one data source and compare their results dynamically.

- Product
- Microsoft Excel Power Pivot
- Device & OS
- not provided
- Scenario
- A user wants to compare segments or periods using a data model, PivotTables, and slicers.
- Observed behavior
- Two selected groups appear side by side and update when their selections change.
Check that your Excel version supports Power Pivot and the TREATAS DAX function. Identify the numeric value to compare and the field that defines each group; the example below uses Amount and Segment.
Compare segments with disconnected selectors and Power Pivot measures
Use two independent slicers to compare sums for different selections from the same segment field.
This example assumes a source table named Sales with Segment and Amount columns. The GroupA and GroupB selector tables must remain unrelated to Sales so that one slicer does not filter the other group.
The measures apply each selector's values to Sales using TREATAS. If a slicer has no filter, its measure includes all segment values in that selector table.
Select the source range, choose Insert > Table, and name the table Sales on the Table Design tab. Select the table and choose Power Pivot > Add to Data Model.
Copy the Sales Segment column to two separate worksheet ranges. Use Data > Remove Duplicates on each range, then choose Insert > Table and name the tables GroupA and GroupB. Add each table to the Data Model using Power Pivot > Add to Data Model.
Open Power Pivot > Manage, then use Diagram View or Manage Relationships to verify that GroupA and GroupB have no relationships to Sales. Remove any automatically created relationships involving the selector tables.
In Excel, choose Power Pivot > Measures > New Measure and create these measures in the Sales table: Group A Amount := CALCULATE(SUM(Sales[Amount]), TREATAS(VALUES(GroupA[Segment]), Sales[Segment])) and Group B Amount := CALCULATE(SUM(Sales[Amount]), TREATAS(VALUES(GroupB[Segment]), Sales[Segment])). Replace the table and column names if yours differ.
Choose Insert > PivotTable and select the workbook's Data Model. Add Group A Amount and Group B Amount to Values, then use PivotTable Analyze > Insert Slicer to add slicers for GroupA[Segment] and GroupB[Segment]. Select a group in each slicer and add a shared category field to Rows if needed.

Explore spreadsheet comparisons in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface and support for Excel files, making it easy to move everyday spreadsheet work between applications. Use WPS Spreadsheets for standard PivotTable analysis; the Excel Power Pivot model and DAX workflow described above require Excel.

Frequently Asked Questions
Why do I need two disconnected selector tables?
Separate GroupA and GroupB tables let each slicer control its own measure. Leave them unrelated to Sales, then use TREATAS in each measure to apply the selected values.
Can I select more than one segment for a group?
Yes. Use the slicer's Multi-Select button or hold Ctrl while selecting items. VALUES passes the selected segments to the corresponding measure.
Why do both measures show the same total?
Check the two slicer selections. If neither slicer is filtered, both measures include all values in their selector tables. Also check that each measure references its own selector table.
How can I compare two periods instead of two segments?
Create two disconnected tables containing the periods to select, add a slicer for each, and adapt the TREATAS measures to apply each selection to the model's date or period field. The exact formula depends on how periods are represented in the data.
Can I show the comparison in a chart?
Yes. Select the completed PivotTable and choose PivotTable Analyze > PivotChart. The chart will reflect changes to the slicers connected to that PivotTable.




