Skip to main content
Steve Rohlf 님이 #Tableau Desktop & Web Authoring에 질문했습니다

We have a business week of Monday through Sunday.  Data is updated weekly on Sunday nights/Monday mornings (usually around 3am). I am grabbing the last 4 weeks of results.  The code {FIXED : MAX(DATE([Settled Date]))} works good when we have data on Sunday but about once a month there is no activity on Sunday.  When this happens it causes the max day to be Saturday.  This causes the last 4 weeks to grab back 1 day to far.

 

This is what I use as the end date(named Max Day):  {FIXED : MAX(DATE([Settled Date]))}

This is what I use as the start date (named Min Day): {FIXED : MAX(DATE([Settled Date]))-27} this would work the same: DATE([Max Day]-27) since they use the same end date. 

 

I am trying to figure a way to set the end/max date to always be the Sunday of the week.  I can get around this if I change the end date to:  {FIXED : MAX(DATE([Settled Date]))+1}

However this means next week when there probably is data from Sunday it will now be the wrong end date.  I can manually do this on Monday mornings but it would be better if I didn't have to do anything, which this would work if there always was Sunday data.

 

At least my labeling showing the dates being used works correctly if it is Sunday or Saturday for the last date using this: 

 

(STR(MONTH([Min Day])) + "/" + STR(DAY([Min Day]))+ "/" + STR(YEAR([Min Day]))

+ " - " +

STR(MONTH([Max Day])) + "/" + STR(DAY([Max Day]))+ "/" + STR(YEAR([Max Day])))

 

The end results use the following:

 

IF [Settled Date] >= [Min Day]

AND [Settled Date] <= [Max Day]

THEN [Revenue] END

 

An example of this is the last 4 weeks.  July 1st was Sunday so it would set Max Day as 7/1/2018 and Min Day as 6/4/2018 but with no Sunday data I am ending up with Max Day as 6/30/2018 and Min Day 6/3/2018.

답변 2개
0/9000