 SOLVED

# DAX Calculate Sum with Filter

I would expect in the below example that in the column "ReplByQty", the first row would be 45 + 14 = 59.

What am I doing wrong? Attached the sample workbook.

4 Replies
best response confirmed by bartvana (Frequent Contributor)
Solution

# Re: DAX Calculate Sum with Filter

That is

``````=VAR currentSKU=Table1[SKU]
RETURN CALCULATE( SUM( Table1[Qty] ),
FILTER( Table1, Table1[ReplBy] = currentSKU ) )``````

Variable is evaluating first and fixed in Returned formula

# Re: DAX Calculate Sum with Filter

@Sergei Baklan Fabulous, thank you!

Just for my understanding, why doesn't it work without the variable?

# Re: DAX Calculate Sum with Filter

@bartvana , you are welcome.

In brief, you fix current row content for scanning the table evaluating formula, without that it is not fixed. It's much better is explained here

Variables in DAX - SQLBI

Solved: Explanation of the EARLIER formula - Microsoft Power BI Community

EARLIER function (DAX) - DAX | Microsoft Docs

Old Earlier worked practically the same way as now VAR.

# Re: DAX Calculate Sum with Filter

@Sergei Baklan OK, thank you!