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
mbegg
Helper II
Helper II

Card with trailing 12 month average

Hi, 

 

I have monthly sales data and a date table. I have calculated trailing 12 month (TTM) average sales. 

 

I want to display TTM for most recent month on a card on a report. 

 

If I add a flag to the data table for the most recent month, and then add that as a filter to the card, the TTM recalculates to use only 1 month worth of data. 

 

Any ideas?

1 ACCEPTED SOLUTION

@GilbertQ thanks for the suggestion. 

 

I found the following worked:

  • Create a column in the date table with 1s & 0s to flag last 12 months.
  • Create the below measure

 

Sales_ttm avg. = 
AVERAGEX( KEEPFILTERS(VALUES('Date'[Date].[Date])), CALCULATE(SUM('Sales'[Value]),'Date'[FLAG_TTM]=1)
)

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @mbegg,

 

I think you can try write a measure and use today function to get last date to filter on TTM measure.
If above not help, can you please share some sample data and the formula?

 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
GilbertQ
Super User
Super User

Hi @mbegg

 

What I would suggest doing is to create your measure where the most recent month is factored into your measure. So that when you put it into your card visual you will not have to still create a filter.


What happens is when you put in a filter, it changes your measures filter context to apply the filter that you added, which is why it then recalculates to only use 1 months worth of data.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

@GilbertQ thanks for the suggestion. 

 

I found the following worked:

  • Create a column in the date table with 1s & 0s to flag last 12 months.
  • Create the below measure

 

Sales_ttm avg. = 
AVERAGEX( KEEPFILTERS(VALUES('Date'[Date].[Date])), CALCULATE(SUM('Sales'[Value]),'Date'[FLAG_TTM]=1)
)

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.