There are so many useful functions in DAX, however, there are also some functions that are not too intuitive to understand. I’ll cover such functions particularly LASTNONBLANK() and LASTNONBLANKVALUE() in the blog post.
Note that the difference I explain in this blog post also applied to FIRSTNONBLANK() and FIRSTNONBLANKVALUE()
I use Contoso dataset in DAX.do for demonstration. Please refer this post for what DAX.do is all about.
What Does LASTNONBLANK Do?
LASTNONBLANK() gives you a value of the specified column where the specified expression is not blank. An example case is where you want get the latest sale date.
LASTNONBLANK() requires two inputs, one is a column, and the other is an expression (think of a measure or aggregation like SUM). When you use it, it would look something like this:
LASTNONBLANK ( 'Date'[Date], [Sales Amount] )
Let’s validate the result if it’s actually doing what it’s supposed to do:
What Does LASTNONBLANKVALUE Do?
LASTNONBLANKVALUE() works in a similar way as LASTNONBLANK() in that it gives you the value of the expression, whereas LASTNONBLANK() gives you the value of the specified column.
Looking at the same example, this is what your code looks like and what your output looks like:
LASTNONBLANKVALUE ( 'Date'[Date], [Sales Amount] )
Now let’s do the same validation:
The Difference Between LASTNONBLANK and LASTNONBLANKVALUE
To put simply, the difference between LASTNONBLANK() and LASTNONBLANKVALUE() is if one gives you the value of your input column vs the value of your input expression. Both can be useful in your analytics use cases. I hope this blog post clarifies your confusion on these functions 🙂