Is FILTER function is an extended version of CALCULATE function ?
I am learning PowerBi and just curious to know the difference between them. I think there is not much difference between them. Filter just return a new table and calculate return scalar value . Correct me please if I am wrong
Gaurvansh Singh Shekhawat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
Key Differences
Return Type:
FILTER: Returns a table.
CALCULATE: Returns a scalar value (single value) such as a number or a date.
Usage:
FILTER: Typically used within other DAX functions that accept a table as an argument. It’s often used within CALCULATE, SUMX, AVERAGEX, etc.
CALCULATE: Used to modify the filter context for an expression. It’s a powerful function for performing context transitions and advanced calculations.
Context Modification:
FILTER: Simply applies a row-wise filter to a table without changing the overall filter context.
CALCULATE: Changes the filter context in which the expression is evaluated, allowing for more complex calculations that depend on modified contexts.
Example Combining Both
You can use FILTER inside CALCULATE to achieve more complex filtering:
DAX
CALCULATE(
SUM(Sales[Quantity]),
FILTER(Sales, Sales[Quantity] > 10)
)