4 Replies Latest reply on Feb 25, 2016 7:48 PM by Shinichiro Murakami

# weekend calculation

Hello -

I need your suggestions on how to calculate data for different weekends based on the launch of a product.

Let's say the item has a launch  date on Tuesday, Wednesday, Thursday or Friday in different country.

For Tuesday the launch weekend will be Tuesday - Sunday of that week.

For Wednesday the launch weekend will be Wednesday - Sunday of that week.

For Thursday the launch weekend will be Thursday - Sunday of that week.

For Friday the launch weekend will be Friday - Sunday of that week.

How can I calculate the launch weekend with "current year USD"  data  by country if it launches on any day...... just the weekend calculation.

Thanks,

JC

• ###### 1. Re: weekend calculation

You didn't provide data, so I will take a guess.

DATETRUNC calculation will give you the beginning of the datepart.

For example

DATETRUNC('week', [Your Date Field]) will give you the date that is the first day of the week of your date field.

Depending on your location or Tableau settings start of week will change but you can always set this. See HERE.

Assuming Sunday is the first day of your week

DATETRUNC('week', [Your Date Field]) will give you the Sunday before the day your provided. But you want the Sunday following the current date. That means you simply need to add a week which makes it

This is the following Sunday. Now you have to define this as the period. Assuming your launch period is between the launch date and the following Sunday

SUM(IF [Date] >= [Launch Date] AND [Date]<=DATEADD('week', 1,DATETRUNC('week', [Launch Date])) THEN [Box Office] ELSE 0 END)

This field would give you the box office for the launch weekend.

2 of 2 people found this helpful
• ###### 2. Re: weekend calculation

I'm not sure I understand your request correctly, but here is my approach.

[Raunch Date]

{fixed[Country]: min(if[Raunch Date flag]='yes' then [Date] end)}

[Weekend Sunday]

datetrunc('week',{fixed[Country]:MAX( [Rauch Date])}+6,"Sunday")

[Raunch Weekend USD]

if [Date]>=[Rauch Date] and [Date]<=[Weekend Sunday] then [USD] end

Thanks,

Shin

9.0 attached.

2 of 2 people found this helpful
• ###### 3. Re: weekend calculation

Thank you both for the great suggestion. I was able to calculate weekend number with both the calculation.

Thanks,

Jitan