3 Replies Latest reply on Dec 13, 2017 1:44 PM by Shinichiro Murakami

# Select N weeks parameter to show YoY by week comparison

Hello!,

This is my first thread! Please, see my attached workbook. I'm trying to solve a YoY comparison (Current year vs. Last year) by week using a parameter (Last N weeks) to control how many weeks appear in the chart, based on the MAX Week of the MAX Year or current year, in this case it's week 48 of 2017, as you will see in the image:

My approach right now isn't doing the job because, as you could've seen, the parameter shows the last 6 weeks based on MAX Week available in the DB, when it should've only shown data for week 43 to 48 (True/False rows in the last image)

Parameter is using this calculation: LAST() < [Last N weeks]

Parameter uses this configuration:

The right solution is:

1. Chart should show last 2 years for the YoY comparsion and weeks to be shown in the chart (parameter) has to be controlled by the MAX Week of the LATEST Year in the Database.

• ###### 1. Re: Select N weeks parameter to show YoY by week comparison

HI Daniel

Welcome to the forum.

Here is one idea.

Overview: Level of Detail Expressions

#### % (modulo)

The % operator returns the remainder of a division operation. For example, 9 % 2 returns 1 because 2 goes into 9 four times with a remainder of 1. Modulo can only operate on integers.

Regards,

Shin

1 of 1 people found this helpful
• ###### 2. Re: Select N weeks parameter to show YoY by week comparison

Hi Shin,

Thank you! Your solution is awesome for this case and also helped me a lot to understand logic behind calc. fields used to reach the solution.

IF [Year Of Calendar]=YEAR(TODAY()) OR [Year Of Calendar]=YEAR(TODAY())-1

THEN 'True' ELSE 'False' END

• ###### 3. Re: Select N weeks parameter to show YoY by week comparison

Hi Daniel,

You are welcome and I hope you enjoy the forum.

Regards,

Shin