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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
PMV
Frequent Visitor

MAT/Rolling annual in DAX start calculating when it makes sense

Hello,

 

I've a question hopefully somebody can help me out.

 

I have a table with units per month of the last 24 months. (see table below)

I want to calculate the MAT in DAX and I use the following DAX below

 

CALCULATE(SUM(Table_1[Units]);DATESINPERIOD(Date_table[Date];LASTDATE(date_table[Date]);-12;MONTH))
 
The formula above is calculating the MAT, but the issue I'm having is the following:
For me MAT or rolling annual is only valid when it has 12 months. But I've only a set of 24 months back, I want that the formula is starting from month 12 (so feb-2019) (the green part of the table). Because that's the first month that is really MAT.
 
 
Probably the solution is easy, but I can't find it.....
 

 

Table.JPG

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @PMV 

If help ,change your measure as below:

measure = 
var measure1=CALCULATE(SUM(Table_1[Units]),DATESINPERIOD(Date_table[Date],LASTDATE(date_table[Date]),-12,MONTH))
return IF(DATEDIFF(CALCULATE(MIN('Table_1'[Date]),ALLSELECTED('Table_1')),MIN('Table_1'[Date]),MONTH)>=12,measure1)

It will show as below.

56.png

Pbix attached

 

If it still unsolved ,please share me your PBIX/some sample data and expected result.

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-easonf-msft
Community Support
Community Support

Hi, @PMV 

If help ,change your measure as below:

measure = 
var measure1=CALCULATE(SUM(Table_1[Units]),DATESINPERIOD(Date_table[Date],LASTDATE(date_table[Date]),-12,MONTH))
return IF(DATEDIFF(CALCULATE(MIN('Table_1'[Date]),ALLSELECTED('Table_1')),MIN('Table_1'[Date]),MONTH)>=12,measure1)

It will show as below.

56.png

Pbix attached

 

If it still unsolved ,please share me your PBIX/some sample data and expected result.

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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