All DAX Functions

The FILTER() Function: Dynamic Row-by-Row Filtering

Scan tables row-by-row for complex filter conditions.

On this page

Overview

The FILTER function is an iterator function. Unlike standard filters that work instantly on an entire column, FILTER goes through your data table row-by-row to scan and check if each row meets your specific condition.

Because it evaluates data row-by-row, it is more powerful and can handle complex logic (like comparing two different columns or checking multiple conditions). However, it requires more processing power.

Syntax

DAX Syntax
FILTER(<table>, <filter_expression>)
  • <table>: The table you want to scan row-by-row.
  • <filter_expression>: The true/false condition you want to test on every single row.

Example & Dataset

Imagine you have a product stock table named Products containing data about current stock levels and safety stock margins:

Sample Data Table: Products

ProductIDProductNameCurrentStockSafetyStockPrice
P01Laptop15101000
P02Smartphone58500
P03Headphones5020100
P04Smartwatch35250

We want to calculate total sales value only for items that are currently running Out of Stock (where CurrentStock is strictly less than SafetyStock). Since we need to compare two columns row-by-row, we must use FILTER() wrapped inside CALCULATE:

The DAX Code

Low Stock Value Measure
Low Stock Value =
CALCULATE(
    SUM(Products[Price]),
    FILTER(
        Products,
        Products[CurrentStock] < Products[SafetyStock]
    )
)

Expected Output Visual

When you drag ProductName and [Low Stock Value] into a Table Visual:

Output Table Visual

ProductNamePrice (Standard)Low Stock Value
Laptop1000BLANK (Stock 15 > Safety 10)
Smartphone500500 (Stock 5 < Safety 8)
Headphones100BLANK (Stock 50 > Safety 20)
Smartwatch250250 (Stock 3 < Safety 5)
Total1850750

Why Did This Output Happen?

The FILTER function scanned the table row-by-row. For "Laptop", 15 < 10 is False, so it returned BLANK. For "Smartphone", 5 < 8 is True, so CALCULATE summed its price ($500).