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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
ChrisN32
Frequent Visitor

Time Intelligence working but not aggregating on totals

Hi all,

 

I'm implementing Time Intelligence, but I need the Time Intelligence to be more explicit. I.e. Current MTD should only show values for the current month (not MTD measures for the previous months as well if no date is selected).

 

Default Time Intelligence MTD expression:

CALCULATE (
     SELECTEDMEASURE (),
     DATESMTD ( ‘Date'[Date] )
)  

 

Adapted TI measures to exclude these extra dates:

CALCULATE ( SELECTEDMEASURE (), DATESMTD ( 'Call Calendar'[Date] ), FILTER ( 'Call Calendar', 'Call Calendar'[Date] >= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ), 01 ) ), FILTER ( 'Call Calendar', 'Call Calendar'[Date] < TODAY () ), ALL ( 'Call Calendar' ) )

 

While this seems to have the intended affect, as per below screenshot, it is not showing any totals/aggregations.

 

ChrisN32_1-1626951276303.png

 

Any advice on where I've gone wrong or what's happening?

 

Cheers

Chris

2 ACCEPTED SOLUTIONS

I removed the filter on all dates, this seems to have fixed the issue and is behaving more like I expect MTD.

 

ChrisN32_0-1626958689350.png

 

Code if anyone is interested:

 CALCULATE ( SELECTEDMEASURE (), FILTER ( 'Call Calendar', 'Call Calendar'[Date] >= EOMONTH ( TODAY (), -1 ) + 1 && 'Call Calendar'[Date] <= TODAY () ) )

Thanks Amit!

View solution in original post

Anonymous
Not applicable

I'm talking about this:

FILTER ( 'Call Calendar', 'Call Calendar'[Date] >= DATE....

What this effectively does is it prevents the directive ALL( 'Call Callendar' ) from taking effect because you're overwriting context with what's in the context already. Such things should never be attempted in DAX code.

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

@ChrisN32 

 

Of course it's ignoring... because you should never put a whole table as a filter into CALCULATE. Only the columns you really need. The golden rule of DAX: You should never filter a table if you can filter a column. This is where your problem is.

Hey Daxer

 

Ahhhh, thanks. Are you referring to this specifically? 

FILTER ( ALL ( 'Call Calendar' )...)
Anonymous
Not applicable

I'm talking about this:

FILTER ( 'Call Calendar', 'Call Calendar'[Date] >= DATE....

What this effectively does is it prevents the directive ALL( 'Call Callendar' ) from taking effect because you're overwriting context with what's in the context already. Such things should never be attempted in DAX code.

ChrisN32
Frequent Visitor

Hi Amit,

 

Thanks for the quick reply! That got my much closer, the total MTD is displaying and looks correct.

 

Unfortunately it's still showing values for other months, in fact it's showing the current MTD against all the other months.

 
 
 

ChrisN32_2-1626954746250.png

 

@ChrisN32 , what you have taken in isfiltered, it should be the table from where the month is coming

 

or try like

 

MTD =
if( isfiltered('Date') || isinscope('Date'[Month]) || isinscope('Date'[Month year]), // change column name as per need
CALCULATE (
SELECTEDMEASURE (),
DATESMTD ( 'Date'[Date] )
)
,
CALCULATE(SELECTEDMEASURE (), FILTER(ALL('Date'),'Date'[Date] >= eomonth(today(),-1)+1 && 'Date'[Date] <= today() ) )
)

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for the help, I'm learning so much! It's ignoring the month completely now

 

ChrisN32_0-1626957159636.png

 

I removed the filter on all dates, this seems to have fixed the issue and is behaving more like I expect MTD.

 

ChrisN32_0-1626958689350.png

 

Code if anyone is interested:

 CALCULATE ( SELECTEDMEASURE (), FILTER ( 'Call Calendar', 'Call Calendar'[Date] >= EOMONTH ( TODAY (), -1 ) + 1 && 'Call Calendar'[Date] <= TODAY () ) )

Thanks Amit!

amitchandak
Super User
Super User

@ChrisN32 , Handle filter

 

MTD =
if( isfiltered('Date'),
CALCULATE (
SELECTEDMEASURE (),
DATESMTD ( 'Date'[Date] )
)
,
CALCULATE(SELECTEDMEASURE (), FILTER(ALL('Date'),'Date'[Date] >= eomonth(today(),-1)+1 && 'Date'[Date] <= today() ) )
)

 

 

Last MTD

 


if( isfiltered('Date'),
CALCULATE (
SELECTEDMEASURE (),
DATESMTD ( dateadd('Date'[Date],-1, month) )
)
,
CALCULATE(SELECTEDMEASURE (), FILTER(ALL('Date'),'Date'[Date] >= eomonth(today(),-2)+1 && 'Date'[Date] <= date(year(today()),month(today()) -1,day(today())) ) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.