Dax Function: Filter Functions

Category: Filter Functions

Filter functions in Power BI’s DAX (Data Analysis Expressions) language are used to create, apply, and manipulate filters on tables and columns. These functions allow for dynamic filtering of data based on conditions or context, which is essential for creating insightful and targeted reports.

Purpose 

The primary purpose of filter functions is to refine datasets by specifying criteria. This enables users to work with subsets of data that meet specific conditions, improving analytical precision and reducing noise in visualizations or calculations.

FunctionDescription
ALLRetrieves all rows from a table or all unique values from a column, ignoring any applied filters.
ALLCROSSFILTEREDClears all cross-filters applied to a table.
ALLEXCEPTRemoves all context filters on a table except those applied to specified columns.
ALLNOBLANKROWReturns all rows or distinct values from a table or column, excluding blank rows, while ignoring context filters.
ALLSELECTEDRemoves context filters applied in the current query, while retaining explicit and other context filters.
CALCULATEComputes an expression in a modified filter context.
CALCULATETABLEEvaluates a table expression in a modified filter context.
EARLIERReturns the value of a specified column from an outer evaluation pass.
EARLIESTSimilar to EARLIER, retrieves the value of a column from the earliest outer evaluation pass.
FILTERProduces a subset of a table based on a condition or expression.
FIRSTNONBLANKReturns the first value in a column where an expression is not blank.
FIRSTNONBLANKVALUEEvaluates an expression for the first value in a column where the result is not blank.
FIRSTFor visuals, retrieves the first row’s value from an axis in the visual matrix.
INDEXFetches a row by its absolute position within a partition, based on sorting criteria or axis order.
KEEPFILTERSAlters how filters are maintained during the evaluation of CALCULATE or CALCULATETABLE functions.
LASTNONBLANKReturns the last value in a column where an expression is not blank.
LASTNONBLANKVALUEEvaluates an expression for the last value in a column where the result is not blank.
LASTFor visuals, retrieves the last row’s value from an axis in the visual matrix.
LOOKUPFor visual calculations, retrieves a value based on applied filters.
LOOKUPWITHTOTALSFor visual calculations, looks up a value with applied filters, ignoring unspecified filters.
LOOKUPVALUEFetches the value that matches all specified search conditions for a row.
MATCHBYIn window functions, specifies columns used to match data and identify the current row.
MOVINGAVERAGEComputes a moving average along a specified axis in the visual matrix.
NEXTFor visuals, retrieves the value from the next row on the axis in the visual matrix.
OFFSETRetrieves a row located a specified number of positions before or after the current row in the same table.
ORDERBYDefines columns that determine the sorting order within partitions of a window function.
PARTITIONBYSpecifies columns that define partitions for a window function.
PREVIOUSFor visuals, retrieves the value from the previous row on the axis in the visual matrix.
RANGEFetches a range of rows relative to the current row along a specified axis; an alias for WINDOW.
RANKCalculates the rank of a row within a defined interval.
REMOVEFILTERSRemoves filters from specified columns or tables.
ROWNUMBERAssigns a unique number to each row based on its ranking within a specified interval.
RUNNINGSUMComputes a cumulative sum along a specified axis in the visual matrix.
SELECTEDVALUEReturns a value when a column is filtered to one distinct value; otherwise, returns an alternate result.
WINDOWProduces multiple rows located within a defined range relative to the current row.

Maximize the potential of Power BI and enhance your data insights with our expert consulting services. Whether you’re looking for assistance with advanced DAX functions, help designing interactive dashboards, or support in optimizing your data models for better performance, our skilled Power BI consultants are ready to provide tailored solutions for your business. Visit our Power BI consultancy page to learn more about how we can empower your organization to make more informed, data-driven decisions.

1. What are filter functions in Power BI?

Filter functions are DAX expressions that allow users to filter and refine data based on specified criteria.

2. Can filter functions modify the source data?

No, DAX operates in a read-only mode. Filter functions create filtered views or subsets of data without changing the original dataset.

3. What is the difference between CALCULATE and FILTER?

CALCULATE modifies the context of an expression by applying filters, while FILTER returns a table containing rows that meet a condition.

4. Can filters be applied to unrelated tables?

Yes, with functions like TREATAS, filters can be applied across unrelated tables.

5. What is the performance impact of using filter functions?

Using complex filters on large datasets can affect performance. Optimize by applying filters early in the data pipeline and avoiding resource-intensive functions.