Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
sifatnabil
Specialist
Specialist

Last 8 weeks last year

Hi,

I have a line graph showing the last 8 weeks of revenue, using the dimension =date(aggr(if(Rank([Week])<=8,[Week]),[Week]),'D MMM')

How can I show the same last 8 weeks but from last year on a line chart?

1 Solution

Accepted Solutions
sifatnabil
Specialist
Specialist
Author

Found a way to get this by using addyears():

dimension:

date([Week],'D MMM')

OR more accurate: Fiscal Week Number


expression (for this year last 8 weeks) -

sum({<Date={'>=$(=WeekStart(Max(Date), -7))<=$(=Date(Max(Date)))'}>} Revenue)

expression (for last year last 8 weeks) -

sum({<Date={'>=$(=WeekStart(addyears(Max(Date),-1), -7))<=$(=Date(addyears(Max(Date),-1)))'}>} Revenue)

View solution in original post

4 Replies
Anonymous
Not applicable

Let VLastyear=max(YearField)-1

Take this as Dim =date(aggr(if(Rank([Week])<=8,[Week]),[Week]),'D MMM')

Expression:  =sum({<YearField={'=$(=VLastyear'}>} sales)

prma7799
Master III
Master III

sifatnabil
Specialist
Specialist
Author

Hi, that doesn't seem to work. It returns the same revenue as sum(Revenue).

sifatnabil
Specialist
Specialist
Author

Found a way to get this by using addyears():

dimension:

date([Week],'D MMM')

OR more accurate: Fiscal Week Number


expression (for this year last 8 weeks) -

sum({<Date={'>=$(=WeekStart(Max(Date), -7))<=$(=Date(Max(Date)))'}>} Revenue)

expression (for last year last 8 weeks) -

sum({<Date={'>=$(=WeekStart(addyears(Max(Date),-1), -7))<=$(=Date(addyears(Max(Date),-1)))'}>} Revenue)