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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Get second earliest date in a column

Hi community, 

I'd like to get the second earliest date in a column of date type. I'm trying the following formula but I'm still getting the earliest, not the second earliest. 

 

second earliest date =
VAR mindate =
CALCULATE ( MIN ( 'Table'[column] ), ALLSELECTED ( 'Table' ) )
RETURN
CALCULATE (
MIN ( 'Table'[column] ),
FILTER ( ALL ( 'Table'), 'Table'[column] < mindate )
)
 
My formula returns 01/01/1000 instead of 01/09/2011

 

Sarah_602_1-1623224610317.png

 

Any idea of what is wrong in my formula?

Thanks

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

Try:
 
second earliest date =
VAR mindate =
CALCULATE ( MIN ( 'Table'[column] ), ALLSELECTED ( 'Table' ) )
RETURN
CALCULATE (
MIN ( 'Table'[column] ),
FILTER ( ALLSELECTED ( 'Table'), 'Table'[column] > mindate )
)




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

2 REPLIES 2
PaulDBrown
Community Champion
Community Champion

Try:
 
second earliest date =
VAR mindate =
CALCULATE ( MIN ( 'Table'[column] ), ALLSELECTED ( 'Table' ) )
RETURN
CALCULATE (
MIN ( 'Table'[column] ),
FILTER ( ALLSELECTED ( 'Table'), 'Table'[column] > mindate )
)




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.






amitchandak
Super User
Super User

@Anonymous , Try like

 

second earliest date =
VAR mindate =
CALCULATE ( MIN ( 'Table'[column] ), ALLSELECTED ( 'Table' ) )
RETURN
CALCULATE (
MIN ( 'Table'[column] ),
FILTER ( ALL ( 'Table'), 'Table'[column] > mindate )
)

 

 

or create a column rank and filter for 2

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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