powerbidaxdata-analysispowerbi-desktopmeasure

Is DAX EARLIER equivalent to using variable to hold the outer context value?


EARLIER(<column>, <number>) 

Is EARLIER technically equivalent to using a variable to hold the value?

For example: if I have a table called Products, then using EARLIER returns the value of the outer context. That is - sales for that product. So = COUNTROWS(FILTER(ProductSubcategory, EARLIER(ProductSubcategory[TotalSubcategorySales])<ProductSubcategory[TotalSubcategorySales]))+1 can be used to return rank of each row relative to other rows.

Is this technically equivalent to doing the calculation by storing the value of outer context in a variable?

var curVal=ProductSubcategory[TotalSubcategorySales]

return COUNTROWS(FILTER(ProductSubcategory, curVal < ProductSubcategory[TotalSubcategorySales]))+1

Solution

  • Essentially yes. EARLIER and EARLIEST are effectively deprecated or discouraged since the introduction of VAR.

    https://www.youtube.com/watch?v=4jWW9kA1lSA