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
ninos-shiba
Resolver I
Resolver I

How to add previous week's value successively each month?

ninosshiba_0-1631133609328.jpeg

I have a table that has each month and each week and is calculating an average. I was trying to unsuccessfully add the previous week's number successively for each week each month. For example, the first week in October has 2.79. The second week should be 2.79+1.51=4.3. The third week in October should be 4.3+1.99=6.29, and so on and so on, repeating of course for each month (week 1). How would I be able to add either a calculated column or measure to be able to do that?

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@ninos-shiba I would not head down the Previous Value route as it leads to sadness and despair. Previous Value aka "Recursion" - Microsoft Power BI Community. Unless it is Power Query and then it is just difficult. In your case, you could do something like:

Measure =
  VAR __MonthStart = MAX('Table'[Month Start])
  VAR __weekinmonth = MAX('Table'[weekinmonth])
  VAR __Table = FILTER(ALL('Table'),[Month Start] = __MonthStart && [weekinmonth]<=__weekinmonth)
RETURN
  SUMX(__Table,[Evals per Rep])

@ 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

1 REPLY 1
Greg_Deckler
Super User
Super User

@ninos-shiba I would not head down the Previous Value route as it leads to sadness and despair. Previous Value aka "Recursion" - Microsoft Power BI Community. Unless it is Power Query and then it is just difficult. In your case, you could do something like:

Measure =
  VAR __MonthStart = MAX('Table'[Month Start])
  VAR __weekinmonth = MAX('Table'[weekinmonth])
  VAR __Table = FILTER(ALL('Table'),[Month Start] = __MonthStart && [weekinmonth]<=__weekinmonth)
RETURN
  SUMX(__Table,[Evals per Rep])

@ 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...

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.