Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SO
Helper III
Helper III

Missing "LastNONBLANKVALUE" Dax function.

Hello,

 

I am trying to find the last value from a table, and was experimenting with LastNonBlank and wasn't getting the correct result and then read some more and realized that I think I should be using LastNonBlankValue, but this Dax function is missing and is not in my latest version of PBI (downloaded January 2022).   Update... I have this function in my data sets that are not live (InService).  Does it not exist in Service? 

 

{75025E84-3C6B-4D95-A079-A5330B799ABF}.png

 

My data looks something like:

LocationIDModelStart DateEnd DateCountStatus
1101F9/9/20219/24/20211a
1101R9/25/20216/30/20221a
1102F9/9/202110/1/20211a
1102R10/2/202110/30/20211a
1102F11/1/20216/30/20221a
2989R 9/9/20216/30/20221a
3988R 9/9/20216/30/20221a
4222R9/9/202111/17/20211a
4222F1/4/20226/30/20221x

 

Using the LastNonBlankValue I was hoping to get to the table below so that I could then use this information to filter values in another table,  

 

Location ID Model Start Date End Date Count Status
1101R9/25/20216/30/20222a
1102F11/1/20216/30/20223a
2989R 9/9/20216/30/20221a
3988R 9/9/20216/30/20221a
4222F1/4/20226/30/20222x

 

My Measure is currently, 

 

# Last2 = LASTNONBLANK('SET'[Startdate], max(SET[Model]))

 

but this only gives me the starting date and does not filter.  I assume it is because I'm not looking at the value.  

 

LocationIDModelStart DateEnd DateCountStatusLast
1101F9/9/20219/24/20211a9/9/2021
1101R9/25/20216/30/20221a9/25/2021
1102F9/9/202110/1/20211a9/9/2021
1102R10/2/202110/30/20211a10/2/2021
1102F11/1/20216/30/20221a11/1/2021
2989R 9/9/20216/30/20221a 9/9/2021
3988R 9/9/20216/30/20221a 9/9/2021
4222R9/9/202111/17/20211a9/9/2021
4222F1/4/20226/30/20221x1/4/2022

 

I was looking at 
@mahoneypa

https://community.powerbi.com/t5/Desktop/Get-the-last-non-blank-value-of-a-column-with-DAX/td-p/1694...

 

and @DataInsights https://community.powerbi.com/t5/Desktop/How-to-get-the-lastnonblank-value-when-I-need-to-keep-sever... 

but can't seem to replicate the answer.  Thoughts?  

2 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

SO
Helper III
Helper III

Dear Ashish Mathur, 

 

I am simply in awe!  Thank you so much!  It is going to take me some time to understand why and how this works.  Thank You - Thank You!!   

Here I was focusing on the one function and you found such an elegant approach.    This is so kind of you.  I very much appreciate this support.  People like you make this such a wonderful community!  

View solution in original post

4 REPLIES 4
DataInsights
Super User
Super User

Nice solution, @Ashish_Mathur. This helped sharpen my understanding of LASTNONBLANK.

 

In case anyone encounters a performance issue (see link below), here's an alternative approach:

 

Last Model = CALCULATE ( MIN ( Data[Model] ), Data[Start Date] = MAX ( Data[Start Date] ) )

 

Last Status = CALCULATE ( MIN ( Data[Status] ), Data[Start Date] = MAX ( Data[Start Date] ) )

 

The September 2021 release introduced the use of aggregation functions in CALCULATE filters when they are used in Boolean (True/False) expressions. The expression MAX ( Data[Start Date] ) evaluates in the filter context of the visual, resulting in the appropriate date being used for each Location and ID.

 

https://www.sqlbi.com/articles/optimizing-lastnonblank-and-lastnonblankvalue-calculations/ 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




SO
Helper III
Helper III

Dear Ashish Mathur, 

 

I am simply in awe!  Thank you so much!  It is going to take me some time to understand why and how this works.  Thank You - Thank You!!   

Here I was focusing on the one function and you found such an elegant approach.    This is so kind of you.  I very much appreciate this support.  People like you make this such a wonderful community!  

You are welcome.  Thank you for your kind words.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.