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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Get last (=newest) non-blank value

This seems easy, but I haven't been able to do that 😞

I'm trying to get the most recent non-blank values from the following table (for two columns).

I need two measures, one for each column that satisfies this task.

The measures should work with the date filter to get the newest one.

 

  

Month EndThis That
31/08/2021 12:00:00 AM  
31/07/2021 12:00:00 AMT&SM&E
30/06/2021 12:00:00 AM  
31/05/2021 12:00:00 AMSJ 
30/04/2021 12:00:00 AMOHTM
31/03/2021 12:00:00 AMTMUS
28/02/2021 12:00:00 AMMJAU
31/01/2021 12:00:00 AM  
31/12/2020 12:00:00 AM  
30/11/2020 12:00:00 AM  

 

Examples for different selected dates:

 

August or July: 

This = T&S

That = M&E

 

June:

This = SJ

That = TM

 

I have tried various dax such as firstnonblank or max, but couldn't achieve this.

 

Please help. Thanks.

1 ACCEPTED SOLUTION

See if this works:

First, the model:

Model.JPGThen the following measures:

 

 

Non Blank "This" = MAXX(FILTER(FactTable, FactTable[This] <> BLANK()), FactTable[This])
Non Blank "That" = MAXX(FILTER(FactTable, FactTable[ That] <> BLANK()), FactTable[ That])
"This" measure =
VAR ThisValue =
    CALCULATE (
        MAX ( 'Calendar Table'[Date] ),
        FILTER (
            ALL ( 'Calendar Table' ),
            'Calendar Table'[Date] <= MAX ( 'Calendar Table'[Date] )
                && NOT ( ISBLANK ( [Non Blank "This"] ) )
        )
    )
RETURN
    CALCULATE (
        LASTNONBLANK ( FactTable[This], FactTable[This] ),
        FILTER (
            ALL ( 'Calendar Table' ),
            'Calendar Table'[Date] <= MAX ( 'Calendar Table'[Date] )
                && 'Calendar Table'[Date] >= ThisValue
        )
    )
"That" Measure =
VAR _Value =
    CALCULATE (
        MAX ( 'Calendar Table'[Date] ),
        FILTER (
            ALL ( 'Calendar Table' ),
            'Calendar Table'[Date] <= MAX ( 'Calendar Table'[Date] )
                && NOT ( ISBLANK ( [Non Blank "That"] ) )
        )
    )
RETURN
    CALCULATE (
        LASTNONBLANK ( FactTable[ That], FactTable[ That] ),
        FILTER (
            ALL ( 'Calendar Table' ),
            'Calendar Table'[Date] <= MAX ( 'Calendar Table'[Date] )
                && 'Calendar Table'[Date] >= _Value
        )
    )

 

 

 

result.JPG

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Have you tried a measure like?

 

measure 1 = lastnonblankvalue(Table[Month End]), Max(Table[This]))

 

measure 2= lastnonblankvalue(Table[Month End]), Max(Table[That]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

 

Yes, it tried it and it does not work 😞 

See if this works:

First, the model:

Model.JPGThen the following measures:

 

 

Non Blank "This" = MAXX(FILTER(FactTable, FactTable[This] <> BLANK()), FactTable[This])
Non Blank "That" = MAXX(FILTER(FactTable, FactTable[ That] <> BLANK()), FactTable[ That])
"This" measure =
VAR ThisValue =
    CALCULATE (
        MAX ( 'Calendar Table'[Date] ),
        FILTER (
            ALL ( 'Calendar Table' ),
            'Calendar Table'[Date] <= MAX ( 'Calendar Table'[Date] )
                && NOT ( ISBLANK ( [Non Blank "This"] ) )
        )
    )
RETURN
    CALCULATE (
        LASTNONBLANK ( FactTable[This], FactTable[This] ),
        FILTER (
            ALL ( 'Calendar Table' ),
            'Calendar Table'[Date] <= MAX ( 'Calendar Table'[Date] )
                && 'Calendar Table'[Date] >= ThisValue
        )
    )
"That" Measure =
VAR _Value =
    CALCULATE (
        MAX ( 'Calendar Table'[Date] ),
        FILTER (
            ALL ( 'Calendar Table' ),
            'Calendar Table'[Date] <= MAX ( 'Calendar Table'[Date] )
                && NOT ( ISBLANK ( [Non Blank "That"] ) )
        )
    )
RETURN
    CALCULATE (
        LASTNONBLANK ( FactTable[ That], FactTable[ That] ),
        FILTER (
            ALL ( 'Calendar Table' ),
            'Calendar Table'[Date] <= MAX ( 'Calendar Table'[Date] )
                && 'Calendar Table'[Date] >= _Value
        )
    )

 

 

 

result.JPG

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors