Excel Power Query: Filter a SUM Calculation with DAX
Question details
The user needs to filter numeric values in the Nr. column while calculating a total from the Amount column.
- Product
- Microsoft Excel Power Query and Power Pivot DAX
- Device & OS
- not provided
- Scenario
- The user is working with tabular data and wants the SUM result to include only rows that meet a numeric condition, such as Nr. greater than 0 or equal to 5.
- Observed behavior
- CALCULATE is being considered for a Power Query formula, although CALCULATE is a DAX function used in the Data Model or Power Pivot rather than standard Power Query.
Confirm whether the calculation belongs in the Power Pivot Data Model or in the Power Query Editor. Check the exact table name and the numeric column names, such as Amount and Nr., before creating the measure or filter.
Create a filtered SUM measure in Power Pivot with DAX
Use this method when the data is loaded into the Excel Data Model or managed through Power Pivot.
CALCULATE changes the filter context of a DAX expression. Add the condition as a CALCULATE argument, and replace the example table and column names with those in your model.
In Excel, select the Power Pivot tab and choose Manage to open the Data Model window.
Select the table containing Amount, choose Home > Calculations > New Measure, and enter a formula such as =CALCULATE(SUM(Data[Amount]),Data[Nr]>0).
For a specific number instead, use a condition such as =CALCULATE(SUM(Data[Amount]),Data[Nr]=5), then replace Data[Amount] and Data[Nr] with the actual table and column names.
Click OK, then insert the measure into a PivotTable or other Data Model report to display the filtered total.
Filter rows in Power Query before aggregating
Use this method when the data transformation must happen in the Power Query Editor before the result is loaded into Excel.
Use WPS Office as a lightweight alternative for filtered spreadsheet totals
WPS Office is a free, lightweight Microsoft Office alternative for opening, editing, and analyzing compatible spreadsheet files. While it does not replace Excel Power Query or Power Pivot DAX, you can migrate the prepared data to WPS Spreadsheets, filter rows, and calculate totals using a familiar interface with seamless XLSX support.
- 1. Open the workbook: Launch WPS Spreadsheet and select Open to import the Excel XLSX file.
- 2. Filter the source data: Select the data range, choose Data > AutoFilter, and apply a condition to the Nr. column.
- 3. Calculate the filtered total: Use a formula such as SUBTOTAL on the filtered Amount column, or create a PivotTable from the filtered data.

Frequently Asked Questions
Can I use CALCULATE directly in Power Query?
No. CALCULATE is a DAX function for Power Pivot and the Excel Data Model. In Power Query, use the column filter menu or an M function such as Table.SelectRows.
How do I sum Amount only when Nr. is greater than zero?
In a Power Pivot measure, use =CALCULATE(SUM(Data[Amount]),Data[Nr]>0). Replace Data, Amount, and Nr. with the actual names in your model.
How can I filter for one exact Nr. value?
Use an equality condition in DAX, such as =CALCULATE(SUM(Data[Amount]),Data[Nr]=5). In Power Query, open the Nr. filter menu and select Number Filters > Equals.
What is the Power Query equivalent of filtering rows before a sum?
Use Table.SelectRows with a row condition, for example Table.SelectRows(Source, each [Nr] > 0), and then load or aggregate the filtered result.




