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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
tokhir
Frequent Visitor

Get last non blank value ordered by date

I have two column: Date and Amount columns

Date

01.11.2024
02.11.2024
03.11.2024
04.11.2024
05.11.2024
06.11.2024
07.11.2024
08.11.2024
09.11.2024
10.11.2024

 

Amount

156209596
129549185
125600180
146158302
137078645

124467960

Null

Null

...

I need get last non blank amount value but filtered with date. If i use dax to get last amount value without any filter, it is ordered from smallest to largest

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @tokhir ,

You can create a measure as below to get it:

Last non blank value = 
VAR _maxdate =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER ( 'Table', NOT ( ISBLANK ( 'Table'[Amount] ) ) )
    )
RETURN
    CALCULATE (
        MAX ( 'Table'[Amount] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] = _maxdate )
    )

vyiruanmsft_0-1731052495498.png

Best Regards

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi @tokhir ,

You can create a measure as below to get it:

Last non blank value = 
VAR _maxdate =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER ( 'Table', NOT ( ISBLANK ( 'Table'[Amount] ) ) )
    )
RETURN
    CALCULATE (
        MAX ( 'Table'[Amount] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] = _maxdate )
    )

vyiruanmsft_0-1731052495498.png

Best Regards

SachinNandanwar
Super User
Super User

Please note that LASTNONBLANK('TableName'[YourValueColumn], 1) will return values based on the natural sort order and not on last value in the column.



Regards,
Sachin
Check out my Blog

got it. Is it possible to get the latest value using simple dax? Or do I need to use a slightly complex query using date?

Try something like this 

 

 

Meausre =
        CALCULATE(
             SUM(Table[Amount]),
             LASTNONBLANK(Table[Date], SUM(Table[Amount]))
         )

 

 



Regards,
Sachin
Check out my Blog
Ankur04
Resolver II
Resolver II

Hi @tokhir ,

 

can you try something like this, please let me know if your requirement is different.

 

Non blank date = VAR maxdate = CALCULATE(MAX('Table (10)'[Date]),'Table (10)'[Amount] <> BLANK())
RETURN CALCULATE(SUM('Table (10)'[Amount]),'Table (10)'[Date] =  maxdate)

 

Thanks,

 

Visharavana
Resolver II
Resolver II

@tokhir If I understand your question correctly, this is one of the solutions.

Last Non-Blank Amount by Date = 
VAR LastDateWithAmount = 
    MAXX(
        FILTER(
            'Table',
            NOT(ISBLANK('Table'[value]))
        ),
        'Table'[Date]
    )
RETURN
LOOKUPVALUE('Table'[value], 'Table'[Date], LastDateWithAmount)
PhilipTreacy
Super User
Super User

@tokhir 

 

Sorry your request is not clear.  What do you mean "If i use dax to get last amount value without any filter, it is ordered from smallest to largest" ?

 

Presumably these columns are in the same table?  If so, why show them separately?

 

Please show a clear example of the result you want.

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Yes, they are both in the same table
If i use LASTNONBLANK('TableName'[YourValueColumn], 1) to get last non blank value from my numeric column its return the biggest one. I dont know why. For test purposes i paste this column to table and yes, its in smallest to largest order not in the format in initial table with date
I just need last non blank value from numeric column in order like in my table(i showed above the example)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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