SOLVED

DAX Calculate Sum with Filter

Frequent Contributor

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?

bartvana_0-1648131779302.png

Attached the sample workbook.

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

@bartvana 

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

@Sergei Baklan Fabulous, thank you!

 

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

@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.

 

@Sergei Baklan OK, thank you!