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!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
I have a calendar table named CT and a sample dataset named Tbl:
Date | Key | Value |
04.08.2022 | A | 3 |
07.08.2022 | A | 7 |
05.08.2022 | B | 11 |
07.08.2022 | B | 13 |
CT is linked to Tbl through Date. A measure is defined to return the date when given key had a value in the fact table:
LastTimeHadValue = MAXX(
FILTER(
ALLEXCEPT(Tbl, Tbl[Key]),
Tbl[Date] <= MAX(CT[Date])
),
Tbl[Date]
)
According to the documentation, ALLEXCEPT() should remove all context filters on Tbl, except for the context filters applied to the Tbl[Key] column.
I expect this:
Date | Key | LastTimeHadValue |
05.08.2022 | A | 04.08.2022 |
05.08.2022 | B | 05.08.2022 |
06.08.2022 | A | 04.08.2022 |
06.08.2022 | B | 05.08.2022 |
But instead get this (some incorrect values are marked with red)
It just returns last date from the fact table (Tbl) when any key had a value, not when key corresponding to the current row had a value - thus ignoring the context filter on Tbl[Key] which it's supposed to keep.
Can anyone explain why?
Hi,
Here ALLEXCEPT is used within FILTER and MAXX. So the issue is with their interaction. Here is a simpler way to do this:
I am using calendar[date] in the column and my data structure is as follows:
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/
Proud to be a Super User!
"Here ALLEXCEPT is used within FILTER and MAXX. So the issue is with their interaction"
So what exactly is the issue here? Why isn't it working as intended?
Also in your code, why do we need to include ALL(CalendarTable) into the filter condition? Not quite getting this part. Is it because otherwise we'd have only one date from calendar as a part of our filter context and we need to get rid of this in order to get proper value?
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
7 | |
5 | |
4 | |
3 |
User | Count |
---|---|
13 | |
11 | |
9 | |
8 | |
8 |