Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Handlordz
New Member

CALCULATETABLE doesn't filter rows with current filter context

Hi everyone,

I have an issue with CALCULATETABLE function:
My fact table 'f_MNT_visits' is connected to a dates table with a range of date from year 2021 to year 2023.
I need to filter my fact table from year selected by user from filter pages.
I expect by using MAX function that fact table will be filtered from filter context (range of dates selected by the user).
I get the max year of date table instead: If user select year 2022, the table is filtered on 2023.
I wrote my dax code like this:


CALCULATETABLE
(
    f_MNT_visits,    
    YEAR ( f_MNT_visits[DatePlan.]) = YEAR ( MAX ( d_dates[Date] ) )
)

 

How can I filter my fact table from year select by the user and not from max value of the dates table.

Thank you in advance for your support.

 

4 REPLIES 4
tamerj1
Super User
Super User

@Handlordz 
Calculated tables do no interact with slicers. They simply do not read the filter context. Dynamic calculated tables are not possible. What are you trying to achieve?

@tamerj1 
Thank you for your feedback and help for my issue.

I have to provide a list of exceptions from a portfolio file that entries don't match with my fact table 'f_MNT_visits'.
Below my complete DAX code which runs well and retuns the number of rows I expect when I specify explicitly the year:

 

Handlordz_1-1673943379546.png

 

However, this list varies according year selected by user from filter panel.
So I need to read dynamically year selected by user to filter the list accordingly.

As I mentionned in my first post, code below get max date from my dates table instead of max date from filter context (when the user selects a specific year).

 

Handlordz_2-1673944023975.png

 

I understand, it is not possible to read the filter context for a virtual table. Could you please confirm me ?

tamerj1
Super User
Super User

@Handlordz 

I assume that you have disabled the interaction between the the visual and the slicer?

@tamerj1 ,

I am not using a visual here, I check the number of rows returned by CALCULATETABLE from data tab.
Year is fixed with value 2022 by user from filter section but number of rows returned correspond to year 2023 

Handlordz_0-1673893156642.png

 

Handlordz_1-1673893419401.png

When I use this expression in a measure "YEAR ( f_MNT_visits[DatePlan.]) = YEAR ( MAX ( d_dates[Date] ) )"
the filter is applied from filter context but for a table generated by CALCULATETABLE the filter is applied from the max value of my dates table.



 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.