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

KB14682: How to create a metric that adds an integer to a datetime column in MicroStrategy Developer 9.x and 10.x


Stefan Zepeda

Salesforce Solutions Architect • Strategy


KB14682: How to create a metric that adds an integer to a datetime column in MicroStrategy Developer 9.x and 10.x

A user has the following two columns of different datatypes:
 

  1. Column of type 'datetime'
  2. Column of type 'Integer'

The user wants to create a metric that adds days (integer metric) to a particular date (datetime metric). The expected result is shown in the table below:
 
 

x 
Column 1 (datetime)Column 2 (Integer)Result12/01/2006312/04/200604/15/20041004/25/2004

x 
Column 1 (datetime)Column 2 (Integer)Result12/01/2006312/04/200604/15/20041004/25/2004

x 
Column 1 (datetime)Column 2 (Integer)Result12/01/2006312/04/200604/15/20041004/25/2004

x 
Column 1 (datetime)Column 2 (Integer)Result12/01/2006312/04/200604/15/20041004/25/2004

x 
Column 1 (datetime)Column 2 (Integer)Result12/01/2006312/04/200604/15/20041004/25/2004

x 
Column 1 (datetime)Column 2 (Integer)Result12/01/2006312/04/200604/15/20041004/25/2004

x 
Column 1 (datetime)Column 2 (Integer)Result12/01/2006312/04/200604/15/20041004/25/2004

x 
Column 1 (datetime)Column 2 (Integer)Result12/01/2006312/04/200604/15/20041004/25/2004

x 
Column 1 (datetime)Column 2 (Integer)Result12/01/2006312/04/200604/15/20041004/25/2004

In order to successfully apply the metric function to combine the result of a datetime column with an integer column, follow the steps below using the Strategy Tutorial project:
 

  • Create a metric called 'metric1' using the attribute 'Ship Date.' This attribute is of type datetime. In this example, a Max function is applied to the metric, as shown below. Based on the purpose of the metric, a related function can be applied to the metric.
ka02R000000kXI0QAM_0EM440000002FMK.jpeg
  • Similarly, create another metric called 'metric2' using the attribute 'Freight.' This attribute is of type Integer. Again in this example, a Max function is applied to the metric, as shown below. Based on the purpose of the metric, a related function can be applied to the metric.
ka02R000000kXI0QAM_0EM440000002FMa.jpeg
  • Create a third metric called 'metric3' using the attribute 'Contract Date'. In this metric use the Date function AddDays, as shown below:
ka02R000000kXI0QAM_0EM440000002FMM.jpeg
  • The AddDays function requires a column type of Date/Time and a column type of integer, as shown below:
ka02R000000kXI0QAM_0EM440000002FMc.jpeg
  • Use 'metric1' and 'metric2' in the AddDays function when defining 'metric 3', as shown below:
ka02R000000kXI0QAM_0EM440000002FMQ.jpeg
  • The final report will look like the result shown below:
ka02R000000kXI0QAM_0EM440000002FMX.jpeg

Comment

0 comments

Details

Knowledge Article

Published:

June 19, 2017

Last Updated:

June 19, 2017