PowerBi DAX equivalent for SUMIFS with current row value as filter -
in excel could, if in table called 'sales' had 4 columns
sales
month, customerid, productid, totalquantity jan,1, car, feb,1, car,
i add formula:
=sumifs(sales[quantity],sales[customerid],[@[customerid]])
that go sales table , sum customerid column filtered customerid of current row formula has been entered.
i attempted replicate in powerbi calculated row can't @ working row reference. comes across like
totalquantity = calculate(sum(sales[quantity]),sales[customerid] = sales[customerid]))
any idea how equivalent @
working?
i think key function missing earlier. not surprising because has misleading name - means "current row". need filter function in filter parameter of calculate, reset filter context entire table.
so new column function might this:
totalquantity = calculate(sum(sales[quantity]), filter(sales, sales[customerid] = earlier (sales[customerid])))
here's neat example, accessible source site dax formulas:
and fwiw here official doco on earlier:
Comments
Post a Comment