Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Previous 8 quarters

Hi All,

I have my dataset which has quarter variable in Qn_YYYY format. Everytime I load data I need my Line chart to display current 8 quarters only.I also have blanks in this variable for the years I dont want to track Quarters

Please help me with this

Thanks in advance

1 Reply
Demlet
Contributor III
Contributor III

Hi Richa,

There is a better way to accomplish this. Load your date into a date table. You can create flags for whatever you want (examples below). Then use those flags in your set analysis/measures to filter the data on your display. Make sure you Floor your date field in the data load. There is a ton on this site explaining this in further detail.

Also... if you don't want specific years - such as anything before 2016. then put that in the vStartDate variable. Your dates will start at that date.

Let vStartDate=Floor(MakeDate(2016,1,1));

Let vEndDate=Floor(Today());

Let vDiff=vEndDate-vStartDate+1;

YourDateTable:

Qualify*;

Unqualify YourDateField;

Load *,

  Date(MonthStart(YourDateField), 'YYYY-MM') As YearMonth,

  Year & '-' & Quarter As YearQuarter,

  WeekYear & '-' & Num(Week, '00') As YearWeek;

Load

  YourDateField,

  Year(YourDateField) As Year,

  Month(YourDateField) As Month,

  Date(YourDateField) As Date,

  Day(YourDateField) As Day,

  Week(YourDateField) As Week,

  'Q' & Ceil(Month(YourDateField)/3) As Quarter,

  WeekYear(YourDateField) As WeekYear,

  -Year2Date(YourDateField) As YTD_Flag,

  -Year2Date(YourDateField, -1) As LYTD_Flag,

  If( DayNumberOfQuarter(YourDateField) <= DayNumberOfQuarter(Today()), 1, 0) as IsInQTD,

  If( Day(YourDateField) <= Day(Today()), 1, 0) as IsInMTD,

  If( Month(YourDateField) = Month(Today()), 1, 0) as IsCurrentMonth,

  If( Month(AddMonths(YourDateField,1)) = Month(Today()), 1, 0) as IsLastMonth,

  If( DayNumberOfYear(YourDateField) <= DayNumberOfYear(Today()), 1, 0 ) as IsInYTD;

Load

  RecNo()-1+$(vStartDate) As YourDateField

AutoGenerate($(vDiff));

-Derek