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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
TotunG
Resolver I
Resolver I

Getting value which is second highest date through date relationship table

Hi,

 

I have a main data table which has a relationship with a reference date table that is used to 'slice' values to compare them in a waterfall chart.

 

I essentially need a measure to give me the Value of the second highest date value but within the filter context of the Month slicer that is also active on the page. 

 

So without filter context, second highest date is: 01/11/23 and therefore value of 4. But I want this to be applied within filter context so say if  Month 12 is not included in the slicer, 2nd highest date would be 3 (01/03/23 - 22). 

 

There is a relationship between these below tables and the slicer is based on the Month column of the Date table.

 

Main Data:

DateValue
01/11/235
01/12/23

4

01/03/232
01/03/221

 

Month / Date Table:

MonthDate
1101/11/23
1201/12/23
301/03/23
301/03/22
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @TotunG ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create two measures. 

rank = RANKX(ALLSELECTED('Main Data'),'Main Data'[Date],MAX('Main Data'[Date]),DESC,Dense)
second highest date value = CALCULATE(MAX('Main Data'[Value]),FILTER(ALLSELECTED('Main Data'),'Main Data'[rank]=2))

(3) Then the result is as follows.

vtangjiemsft_0-1686189835366.png

vtangjiemsft_1-1686189861541.png

Best Regards,

Neeko Tang

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @TotunG ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create two measures. 

rank = RANKX(ALLSELECTED('Main Data'),'Main Data'[Date],MAX('Main Data'[Date]),DESC,Dense)
second highest date value = CALCULATE(MAX('Main Data'[Value]),FILTER(ALLSELECTED('Main Data'),'Main Data'[rank]=2))

(3) Then the result is as follows.

vtangjiemsft_0-1686189835366.png

vtangjiemsft_1-1686189861541.png

Best Regards,

Neeko Tang

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

Thank you for your input, although I think its a bit more complex due to the relationship of the date table that I dont think you cover. 

 

This Sample PBI might explain it better:

 

https://drive.google.com/file/d/19KDNuA7CRElc-O1H8WwschGNoU29qUBv/view?usp=sharing

Anonymous
Not applicable

Hi @TotunG ,

 

The two tables in your pbix file do not have any date columns, please check your pbix file.

 

Best Regards,

Neeko Tang

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors