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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Second latest date with data

Hi, 

 

I have a measure that shows data from the latest possible day and it works as expected. Somehow I fail building a measure for the second latest date because it is always showing data for the next day after latest and new data is not coming in daily. The timestamp value has a relation with the Date table.

 

Measure for latest works as expected:

Measure 1 =

var _latestday = CALCULATE(MAX('Date'[Date]))

RETURN
CALCULATE(SUM('Table'[count]), 'Table'[timestamp] = _latestday)

 

Measure for second latest works is returning second latest date even if count is blank.

Measure 2 =
var _secondlatestday = CALCULATE(MAX('Date'[Date]))-1

RETURN
CALCULATE(SUM('Table'[count]), 'Table'[timestamp] = _secondlatestday)

 

So today Measure 1 is returning 100 and Measure 2 blank when 140 is expeted. On Friday 8th of October Measure 1 was returning 140 and Measure 2 was returning 80. On Friday I thought my measure was working fine but today I realized something needs to be fixed.

 

timestampcount
10/10/21100
8/10/21140
7/10/2180
5/10/219
3/10/21-2

 

Thanks for your help in advance!

 

Julia

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @Anonymous 

 

try this:

VAR _2nd =
    CALCULATE (
        MAX ( 'Table'[timestamp] ),
        FILTER ( ALL ( 'Table' ), 'Table'[timestamp] < MAX ( 'Table'[timestamp] ) )
    )
RETURN
    CALCULATE ( SUM ( 'Table'[count] ), 'Table'[timestamp] = _2nd )

output:

VahidDM_0-1633956274012.png

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!


 
 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thanks a lot @VahidDM ! Your solution worked for my problem.

VahidDM
Super User
Super User

Hi @Anonymous 

 

try this:

VAR _2nd =
    CALCULATE (
        MAX ( 'Table'[timestamp] ),
        FILTER ( ALL ( 'Table' ), 'Table'[timestamp] < MAX ( 'Table'[timestamp] ) )
    )
RETURN
    CALCULATE ( SUM ( 'Table'[count] ), 'Table'[timestamp] = _2nd )

output:

VahidDM_0-1633956274012.png

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!


 
 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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