Forum Discussion
Slicers in Excel
I have financial data in an Excel spreadsheet. I've created slicers for certain columns and a table adjacent to the slicers to display total financial figures for two years. My question is: If I write a formula to calculate total revenue, expenses, and profit in the table beside the slicers, can I integrate these calculations with the existing slicers? In other words, would slicing any field automatically update the financial data in the table as well as the other data on the sheet?
3 Replies
- PeterBartholomew1Silver Contributor
Another approach is to create a helper column that returns a 1 for a visible record and 0 for a hidden record
= SUBTOTAL(2, [@ID])
The totals are returned by
= SUMIFS(Table1[2021 Revenue], Table1[Filter], 1) or = Table1[[#Totals],[2021 Revenue]] where the Table Totals row has the formula = Table1[[#Totals],[2021 Revenue]]
The summary financial data requires one or more formulas and should not itself be a table. Something else that is possible using 365 is to return a column of filtered values on another sheet using
= FILTER(HSTACK(Table1[ID], Table1[2021 Revenue]), Table1[Filter])
- Mks_1973Iron Contributor
it has been difficult to read the attached file and guide accordingly, but you may see the below for your own to work in your file:
-------------------------------------------------------
Yes, you can integrate calculations (e.g., total revenue, expenses, and profit) with slicers in Excel so that adjusting any slicer automatically updates the financial data in the adjacent table. Here’s how you can achieve this:How Slicers Work
Slicers act as visual filters for your data, typically linked to an Excel Table or Pivot Table.
Formulas that reference these filtered tables or Pivot Tables dynamically update based on slicer selections.
Format Your Data as a Table:Select your financial data, go to the "Insert" tab, and click "Table."
Ensure headers are correctly named (e.g., Year, Revenue, Expenses, Profit).
Insert Slicers:With the table selected, go to the "Table Design" tab and click "Insert Slicer."
Add slicers for relevant columns (e.g., Year, Region).
Write Formulas with SUBTOTAL:SUBTOTAL dynamically calculates values for visible rows only (i.e., rows filtered by slicers).
Example formulas:
Total Revenue: =SUBTOTAL(109, Table1[Revenue])
Total Expenses: =SUBTOTAL(109, Table1[Expenses])
Profit: =SUBTOTAL(109, Table1[Revenue]) - SUBTOTAL(109, Table1[Expenses])
Place these formulas in the adjacent table.2. Using a Pivot Table
Create a Pivot Table:Go to the "Insert" tab and select "Pivot Table."
Use your financial data as the source.
Drag fields (e.g., Year, Revenue, Expenses) into appropriate rows, columns, and values.
Add Slicers:Select the Pivot Table, go to the "PivotTable Analyze" tab, and click "Insert Slicer."
Add slicers for fields like Year, Region.
Use GETPIVOTDATA for Calculations:Link your formulas to the Pivot Table using GETPIVOTDATA.
Example:
Total Revenue: =GETPIVOTDATA("Revenue", PivotTable!$A$3)
Profit: =GETPIVOTDATA("Revenue", PivotTable!$A$3) - GETPIVOTDATA("Expenses", PivotTable!$A$3)
These formulas dynamically update when slicers are adjusted.Best Practices to use Structured References:
If working with a table, structured references (e.g., Table1[Revenue]) ensure formulas remain dynamic and easy to manage.
Keep Slicers Linked to the Same Data Source:
All slicers must filter the same table or Pivot Table for consistent updates.
Test and Validate: Adjust slicers to ensure the formulas in the adjacent table update correctly.
When to Choose Each Approach
Structured Table + SUBTOTAL: Ideal for smaller datasets or when you want simple calculations.
Pivot Table + GETPIVOTDATA: Preferred for large datasets or when you need summary calculations with grouped data (e.g., totals by year or region). - Detlef_LewinSilver Contributor
Just try it.