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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

return the second max date per month

Hi, I am trying to get the second max date per month. Please see below output.

 

Report Date         Second Max Date

  5/1/2020                  5/20/2020 

  5/30/2020                5/20/2020 

  5/20/2020                5/20/2020 

  6/30/2020                6/15/2020

  6/15/2020                6/15/2020 

  6/01/2020                6/15/2020 

 

My current measure is

Second Max Date = CALCULATE(MAX('Table1'[Report Date]), FILTER('Table1', 'Table1'[Report Date]<>MAX('Table1'[Report Date])))

 

However, it returns to me this output

Report Date         Second Max Date

  5/1/2020                  6/15/2020 

  5/30/2020                6/15/2020 

  5/20/2020                6/15/2020 

  6/30/2020                6/15/2020

  6/15/2020                6/15/2020 

  6/01/2020                6/15/2020 

 

Please advise how can i get the correct output. 

Thanks.

1 REPLY 1
az38
Community Champion
Community Champion

Hi @Anonymous 

try

Second Max Date = 
var _maxDate = CALCULATE(MAX('Table1'[Report Date]), ALLEXCEPT('Table1', 'Table1'[Report Date].[Month]) )

RETURN

CALCULATE(MAX('Table1'[Report Date]), ALLEXCEPT('Table1', 'Table1'[Report Date].[Month]), 'Table1'[Report Date] < _maxDate)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

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.