EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB9585: How to create a Year to Day expression using an Applysimple function in MicroStrategy Developer


Stefan Zepeda

Salesforce Solutions Architect • Strategy


How to create a Year to Day expression using an Applysimple function in MicroStrategy Developer

In certain circumstances it is desirable for business purposes to compare data for one year ago on a day of the week basis (i.e., Tuesday should line up with a Tuesday one year ago).
 
Simply subtracting 365 days, however, will skew the data as it fails to take into account either leap years, or the fact that one year ago today does not fall on the same day of the week. There are database functions which can perform this calculation, but there is also a way to force Strategy to perform this calculation.
 
The following procedure describes how to achieve this:
 

  1. Create a new attribute, based off of the table containing data for both the relevant day(s), and the previous year (for this example, the column will be named "Day").
  2. In this attribute, create an applysimple with the following expression:
    ApplySimple("#0-364", Day)
  3. For more information on creating an applysimple, refer to Strategy Knowledge Base document, KB5700-007-0113 - How to implement attribute form expression using Apply Functions in Strategy Desktop.
     

Since there are 7 days in each week and 52 weeks in each year, this calculation will always match each day of the week to the appropriate week of the previous year regardless of leap years.
 
NOTE: As each database handles the formatting of dates slightly differently, this exact syntax may not be appropriate. A database administrator should be able to provide the correct syntax for a given database.
 


Comment

0 comments

Details

Knowledge Article

Published:

June 13, 2017

Last Updated:

June 13, 2017