cancel
Showing results for
Did you mean:
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:

 Date Value 01/11/23 5 01/12/23 4 01/03/23 2 01/03/22 1

Month / Date Table:

 Month Date 11 01/11/23 12 01/12/23 3 01/03/23 3 01/03/22
1 ACCEPTED SOLUTION
Community Support

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.

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.

3 REPLIES 3
Community Support

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.

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.

Resolver I

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:

Community Support

Hi @TotunG ,

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

Best Regards,

Neeko Tang

Announcements

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Top Solution Authors
Top Kudoed Authors