Menu
Stuff by Yuki
  • Home
  • Python
  • Power BI
  • Tableau
  • Community
    • Makeover Monday
    • Workout Wednesday
  • About
  • Contact
Stuff by Yuki

The Difference Between LASTNONBLANK and LASTNONBLANKVALUE in DAX

Posted on May 12, 2023May 12, 2023

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:

Copy Copied Use a different Browser

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:

Copy Copied Use a different Browser

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 🙂

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How to Convert String to Date or Datetime in Polars
  • Aggregations Over Multiple Columns in Polars
  • DuckDB with Polars, Pandas, and Arrow
  • Read from and Write to Amazon S3 in Polars
  • Handling Missing Values in Polars

Popular Posts

  • A Running Total Calculation with Quick Measure in Power BI
  • How To Copy And Paste Report Page in Power BI
  • How to Fill Dates Between Start Date and End Date in Power BI (Power Query)
  • Year-Over-Year Calculation: Time Intelligence in Power BI
  • Network Visualizations in Python

connect with me

  • LinkedIn
  • Twitter
  • Github
©2023 Stuff by Yuki | Powered by SuperbThemes & WordPress