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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.