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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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