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
Anonymous
Not applicable

4 weeks cumulate and evolution

Hello, I have a model without time intelligence.

I have my dimTable with weeks

And I want to have Sales cumulative for last 4 weeks

Then I want to compare for each week sales evolution of 4 last weeks (put it in the chart)

For example we are Week 43, I would like to have the sums ({43,42,41,40}/{42,41,40,39}) - 1 ect.

Could you please suggest the right way to do that?

 

Thank you

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

Hi @Anonymous ,

 

This is my test table:

vyadongfmsft_0-1667442244920.png

 

Create a new column:

 

 

 

WeekNumber = WEEKNUM('Sheet7'[Date])

 

 

 

vyadongfmsft_0-1668070417839.png

 

 

Create a measure to calculate Sales cumulative for last 4 week:

 

 

 

Sales cumulative for last 4 weeks = 
var max_week = MAX('Sheet7'[WeekNumber])
return
CALCULATE(SUM('Sheet7'[Sales]), FILTER('Sheet7','Sheet7'[WeekNumber] <= max_week && 'Sheet7'[WeekNumber] >= max_week - 3 ))

Sales cumulative for last 4 weeks -1 = 
var max_week = MAX('Sheet7'[WeekNumber])-1
return
CALCULATE(SUM('Sheet7'[Sales]), FILTER('Sheet7','Sheet7'[WeekNumber] <= max_week && 'Sheet7'[WeekNumber] >= max_week - 3 ))

Measure = DIVIDE([Sales cumulative for last 4 weeks] , [Sales cumulative for last 4 weeks -1]) -1

 

 

 

Is this the result you want?

vyadongfmsft_3-1668071379765.png

 

Best regards,

Yadong Fang

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

2 REPLIES 2
v-yadongf-msft
Community Support
Community Support

Hi @Anonymous ,

 

This is my test table:

vyadongfmsft_0-1667442244920.png

 

Create a new column:

 

 

 

WeekNumber = WEEKNUM('Sheet7'[Date])

 

 

 

vyadongfmsft_0-1668070417839.png

 

 

Create a measure to calculate Sales cumulative for last 4 week:

 

 

 

Sales cumulative for last 4 weeks = 
var max_week = MAX('Sheet7'[WeekNumber])
return
CALCULATE(SUM('Sheet7'[Sales]), FILTER('Sheet7','Sheet7'[WeekNumber] <= max_week && 'Sheet7'[WeekNumber] >= max_week - 3 ))

Sales cumulative for last 4 weeks -1 = 
var max_week = MAX('Sheet7'[WeekNumber])-1
return
CALCULATE(SUM('Sheet7'[Sales]), FILTER('Sheet7','Sheet7'[WeekNumber] <= max_week && 'Sheet7'[WeekNumber] >= max_week - 3 ))

Measure = DIVIDE([Sales cumulative for last 4 weeks] , [Sales cumulative for last 4 weeks -1]) -1

 

 

 

Is this the result you want?

vyadongfmsft_3-1668071379765.png

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Let's simplify my question : 

We are week 43 - I want to create groups of 4 weeks starting with last available week

So W43,42,41,40 should be group 11, W39,38,37,36 should be group 10 ect.

How would you do that?

Thank you

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.