We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
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
)
Did I answer your question? If so, please mark my post as a solution!
Proud to be a Super User!
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
Did I answer your question? If so, please mark my post as a solution!
Proud to be a Super User!
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 have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 54 | |
| 39 | |
| 32 | |
| 17 | |
| 15 |
| User | Count |
|---|---|
| 64 | |
| 63 | |
| 37 | |
| 36 | |
| 22 |