Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Solved! Go to Solution.
Hi @AnthonyXelya - Can you share the sample data for reference
I have removed both all and allselected,CALCULATETABLE to create a filtered version of MyTable that only includes rows where the Date column falls within the specified date range of the previous year.
Try this
Median Last Year =
VAR minDate = DATE(YEAR(MIN(Calendar[Date])) - 1, MONTH(MIN(Calendar[Date])), DAY(MIN(Calendar[Date])))
VAR maxDate = DATE(YEAR(MAX(Calendar[Date])) - 1, MONTH(MAX(Calendar[Date])), DAY(MAX(Calendar[Date])))
VAR FilteredTable =
CALCULATETABLE(
MyTable,
Calendar[Date] >= minDate && Calendar[Date] <= maxDate
)
VAR Result =
MEDIANX(
SUMMARIZE(
FilteredTable,
MyTable[Id_Entity],
"Sum", SUM(MyTable[Value])
),
[Sum]
)
RETURN Result
Proud to be a Super User! | |
Still nobody to help me? 😞
Hi @AnthonyXelya Modified 2nd forumale for previous year, It will correctly calculate the median for the previous year check below measure:
Median Last Year =
VAR minDateCurrentYear = MIN(Calendar[Date])
VAR maxDateCurrentYear = MAX(Calendar[Date])
VAR minDatePreviousYear = DATE(YEAR(minDateCurrentYear) - 1, MONTH(minDateCurrentYear), DAY(minDateCurrentYear))
VAR maxDatePreviousYear = DATE(YEAR(maxDateCurrentYear) - 1, MONTH(maxDateCurrentYear), DAY(maxDateCurrentYear))
VAR Result =
MEDIANX(
SUMMARIZE(
MyTable,
MyTable[Id_Entity],
"Sum", CALCULATE(
SUM(MyTable[Value]),
FILTER(
ALL(Calendar[Date]),
Calendar[Date] >= minDatePreviousYear &&
Calendar[Date] <= maxDatePreviousYear
)
)
),
[Sum]
)
RETURN
Result
Hope it works. pls check
Proud to be a Super User! | |
Thanks for your answer... sadly it doesn't change anything 😞
Hi @AnthonyXelya -To ensure the context of other filters is maintained, we can use ALLSELECTED instead of ALL
Median Last Year =
VAR minDate = DATE(YEAR(MIN(Calendar[Date]))-1, MONTH(MIN(Calendar[Date])), DAY(MIN(Calendar[Date])))
VAR maxDate = DATE(YEAR(MAX(Calendar[Date]))-1, MONTH(MAX(Calendar[Date])), DAY(MAX(Calendar[Date])))
VAR Result =
MEDIANX(
SUMMARIZE(
MyTable,
MyTable[Id_Entity],
"Sum",
CALCULATE(
SUM(MyTable[Value]),
FILTER(
ALLSELECTED(Calendar),
Calendar[Date] >= minDate && Calendar[Date] <= maxDate
)
)
),
[Sum]
)
RETURN Result
If this approach still doesn’t work, it might be helpful to inspect the underlying data or test the calculation in a simple scenario to isolate the issue.
Proud to be a Super User! | |
Sadly, still the same :
Hi @AnthonyXelya - Can you share the sample data for reference
I have removed both all and allselected,CALCULATETABLE to create a filtered version of MyTable that only includes rows where the Date column falls within the specified date range of the previous year.
Try this
Median Last Year =
VAR minDate = DATE(YEAR(MIN(Calendar[Date])) - 1, MONTH(MIN(Calendar[Date])), DAY(MIN(Calendar[Date])))
VAR maxDate = DATE(YEAR(MAX(Calendar[Date])) - 1, MONTH(MAX(Calendar[Date])), DAY(MAX(Calendar[Date])))
VAR FilteredTable =
CALCULATETABLE(
MyTable,
Calendar[Date] >= minDate && Calendar[Date] <= maxDate
)
VAR Result =
MEDIANX(
SUMMARIZE(
FilteredTable,
MyTable[Id_Entity],
"Sum", SUM(MyTable[Value])
),
[Sum]
)
RETURN Result
Proud to be a Super User! | |
It's working! Thank you very much dude!!
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 46 | |
| 42 | |
| 23 | |
| 18 |
| User | Count |
|---|---|
| 193 | |
| 124 | |
| 101 | |
| 67 | |
| 49 |