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
kressb
Helper V
Helper V

Calculating a MTD Average based on Date and Entity

Hello,

I have a table with a number by person by date. I want to calculate the average for current month/month(s) previous.
I've tried 2 calculations, neither work:

  1. Average#MTD = Averagex(values(Table[Date].[Date], [Number]) - returns the Number for each Month 
  2. Average#MTD= CALCULATE(AVERAGEX(Table,Table[Number]),Filter(Table,Table[Date].[Date]<=EARLIER(Table[Date].[Date]))) - gives me the average by date, but not to specific person (UniqueID2). 
    Do I just need another filter here? 
    SumingRows.DesiredResult.Avg.png

Understand the preference is to provide a pbix file. I unfortunately am not able to do that. Appreciate any help anyone is willing to provide without pbix files. I am very close to getting to what I need, but am missing something small I think..

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@kressb - Are these calculated columns or measures? Look like calculated columns. Try:

Average#MTD= AVERAGEX(Filter(Table,Table[Date].[Date]<=EARLIER(Table[Date].[Date] && [Name]=EARLIER(Table[Name])),Table[Number])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@kressb - Are these calculated columns or measures? Look like calculated columns. Try:

Average#MTD= AVERAGEX(Filter(Table,Table[Date].[Date]<=EARLIER(Table[Date].[Date] && [Name]=EARLIER(Table[Name])),Table[Number])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Yepp! That did it - THANK YOU very much for the help! 

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.