Menu
Stuff by Yuki
  • Home
  • Data Engineering
    • Python
  • Business Intelligence
    • Power BI
    • Tableau
  • Perspectives
  • 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

  • Where I’m Headed in the Next 5 Years
  • Open-Source vs Vendor Data Tools
  • Developing the Habit of Writing
  • How to Inspect and Optimize Query Plans in Python Polars
  • Learn Python Polars with Polars Cookbook

Popular Posts

  • A Running Total Calculation with Quick Measure in Power BI
  • A Complete Guide to Git Integration in Power BI
  • How To Copy And Paste Report Page in Power BI
  • Handling Missing Values in Polars
  • How to Convert String to Date or Datetime in Polars

connect with me

  • LinkedIn
  • Twitter
  • Github
  • Website

Search Articles

©2025 Stuff by Yuki | Powered by SuperbThemes