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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.