Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more
Hi guys
I am quite new to Power BI and I am struggling now with getting the value from the second latest date. So i have a table "Gesamt" like the following
| Name Code | Datum | Gewicht | DIFFDate |
| Person 1 | 15.01.2024 | 88 | 31 |
| Person 1 | 16.01.2024 | 89 | 30 |
| Person 1 | 17.01.2024 | 87 | 29 |
| Person 1 | 18.01.2024 | 88.5 | 28 |
| Person 1 | 19.01.2024 | 89.5 | 27 |
| Person 1 | 20.01.2024 | 87.5 | 26 |
| Person 2 | 21.01.2024 | 60.5 | 25 |
| Person 2 | 22.01.2024 | 60 | 24 |
| Person 2 | 23.01.2024 | 61 | 23 |
| Person 2 | 24.01.2024 | 59.5 | 22 |
| Person 2 | 15.01.2024 | 59 | 31 |
| Person 3 | 13.01.2024 | 70 | 33 |
| Person 3 | 14.01.2024 | 71 | 32 |
| Person 3 | 15.01.2024 | 69 | 31 |
| Person 3 | 16.01.2024 | 69.5 | 30 |
| Person 3 | 17.01.2024 | 70.5 | 29 |
| Person 3 | 18.01.2024 | 71.5 | 28 |
| Person 3 | 24.01.2024 | 72 | 22 |
I calculated the newest value of "Gewicht* with
//Try this
DifferenceSecondLatestLast =
VAR LatestRank = RANKX(ALL(Gesamt), CALCULATE(AVERAGE(Gesamt[DIFF Date])))
VAR SecondLatestRank = LatestRank - 1
RETURN
CALCULATE(
AVERAGE(Gesamt[Gewicht]),
FILTER(ALL(Gesamt), Rank IN {LatestRank, SecondLatestRank})
) -
CALCULATE(
AVERAGE(Gesamt[Gewicht]),
Rank = LatestRank
)
Hi
if I try this, I got an error message (as in the picture).
Even if I put the "Rank" in [ ] to define it's the measure, it's not working.
Also the "Latest Rank" does not define the latest rank, right? IS there a "Max" missig?
Thanks
You can add visual filter it works with measures and put the rank measure value to 2
Thanks Muhammad for your reply.
As I mentioned I want to calculate in another step with the second latest value (at the end it's the difference between the latest and the second latest). So only by filtering the visual it won't work. Or am I thinking in a wrong way?
If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!
Check out the July 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 29 | |
| 28 | |
| 20 | |
| 20 | |
| 19 |
| User | Count |
|---|---|
| 35 | |
| 28 | |
| 21 | |
| 19 | |
| 17 |