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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply

Get the 2nd to the Latest/Last Value of a column

Hey, 
So I wanted to get the 2nd latest/last value of a column, say for example:

IDNameValue
1Test10
2Test269
3Test342

in this scenario, I need to get the 2nd to the last row which is 69. 

how can i get this in a measure or column?

Thanks yall, much appreciated.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @EvanGetsItDone ,

You can create a measure as below to get it, please find the details in the attachment.

2nd latest value = 
VAR _maxid =
    CALCULATE ( MAX ( 'Table'[ID] ), ALLSELECTED ( 'Table' ) )
VAR _secondmid =
    CALCULATE (
        MAX ( 'Table'[ID] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ID] < _maxid )
    )
RETURN
    CALCULATE (
        MAX ( 'Table'[Value] ),
        FILTER ( 'Table', 'Table'[ID] = _secondmid )
    )

vyiruanmsft_0-1706497169974.png

Best Regards

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @EvanGetsItDone ,

You can create a measure as below to get it, please find the details in the attachment.

2nd latest value = 
VAR _maxid =
    CALCULATE ( MAX ( 'Table'[ID] ), ALLSELECTED ( 'Table' ) )
VAR _secondmid =
    CALCULATE (
        MAX ( 'Table'[ID] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ID] < _maxid )
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER ( 'Table', 'Table'[ID] = _secondmid )
    )

vyiruanmsft_0-1706169798661.png

Best Regards

Idrissshatila
Super User
Super User

Hello @EvanGetsItDone ,

 

try the following


2nd Last Value = CALCULATE(MAX('Table'[Value]),'Table'[ID] = MAX('Table'[ID])-1)

Idrissshatila_0-1706121434141.png

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Hello Thanks!

Would this be possible for a text? let's say, the values are:

IDNameValue
1Test1a
2Test2b
3Test3c



I would like to get the b, which is the 2nd last value, but it is a text. 

Thanks!

Hi,

Does second last have to be determined based on numbers being in the ID column?


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

Hi,

Does second last have to be determined based on numbers being in the ID column?


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

Hi @EvanGetsItDone ,

You can create a measure as below to get it, please find the details in the attachment.

2nd latest value = 
VAR _maxid =
    CALCULATE ( MAX ( 'Table'[ID] ), ALLSELECTED ( 'Table' ) )
VAR _secondmid =
    CALCULATE (
        MAX ( 'Table'[ID] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ID] < _maxid )
    )
RETURN
    CALCULATE (
        MAX ( 'Table'[Value] ),
        FILTER ( 'Table', 'Table'[ID] = _secondmid )
    )

vyiruanmsft_0-1706497169974.png

Best Regards

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.