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 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
Hi everyone,
I have a table with 2 columns: DATE and VALUE
I need a calculated column with the value of the column VALUE ranked against the other values of the column VALUE that are released in the last 20 years (ending on the DATE value of that particular row).
I tried replacing AVERAGEX in this formula with RANKX but without success.
Moving_Average_20_Years = CALCULATE (
AVERAGEX ( ALLSELECTED('Session'), 'Session'[Sessions] ),
DATESINPERIOD (
'Session'[FullDate],
LASTDATE ( 'Session'[FullDate] ),
-20,
YEAR
)
)What should I do?
Thank you very much!
Solved! Go to Solution.
I think I found the solution:
Hi @IvanG92 ,
try these 2 calculated columns:
1)
This evaluates the rank against the current year, but I don't want the march value tu be evaluated against future values, only last x past values!
Hi @IvanG92 ,
with my formulas you get the rank for example for the last 24 month from 31.12.1872
Can you show me graphically how is your expected result?
I think I found the solution:
Let's use 12 months for better visual clarity:
I need each current row to be evaluated against ONLY PAST VALUES. Your fomula evaluate february 2020 for example against the entire 2020 and 2019. Instead it should evaluate the rank against feb18 - feb20. It's exactly like a "moving average", but is a "moving rank".
Sure! Here's the file: https://we.tl/t-tBWmKmgpcs
I need to rank (in the table D_YIELD) the column "S&P500 D_Yield (Abs)" against the other values, but not against the entire column, just against the last x years, month, or days. Using a RANKX againt the whole table will return values from 1 to 1800 since the column is made of 1800 rows. With the correct expression I expect values only from 1 to say 24 if I choose to evaluate the rank against the last 2 years (each row correspond to a month). Is that clear enough?
Hi @IvanG92,
You can use:
Rank = RANKX(FILTER(ALL('Session'), DATESINPERIOD('Session'[FullDate], MAX('Session'[FullDate]),-20,YEAR)),'Session'[Value],,ASC)
Works for you? Mark this post as a solution if it does!
Consider taking a look at my blog: Forecast Period - Previous Forecasts
It throws an error: "A table of multiple values was supplied where a single value was expected"
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.
| User | Count |
|---|---|
| 22 | |
| 20 | |
| 14 | |
| 13 | |
| 13 |
| User | Count |
|---|---|
| 62 | |
| 40 | |
| 38 | |
| 38 | |
| 38 |