DateSeries([OutputFrequency: MsFrequency = 0]): Variant;
DateSeries(OutputFrequency: Prognoz.Platform.Interop.Ms.MsFrequency, Context: Prognoz.Platform.Interop.Fore.ForeRuntimeContext): object;
OutputFrequency. Calendar frequency of output series. The parameter is equal to calculation frequency by default. For example, if the calculation period from 2015 to 2020 is set, and the method is used as DateSeries(MsFrequency.Monthly), all months of the specified calculation period are obtained.
NOTE. If the parameter is not set, an output series is created with the current calculation frequency.
Context. Context. The parameter is used only in Fore.NET.
The DateSeries method returns the current date value for each series point depending on the specified calculation periods.
It is used to calculate determinate equation:
If the pointwise calculation method is selected, the method returns calculation date.
If the series calculation method is selected, the method returns the time series, in which calculation points correspond to dates.
Executing the example requires that the repository contains a modeling container with the MS identifier that contains a model with the MODEL_D identifier. The model is calculated by the determinate equation method and contains at least one input variable.
Add links to the Metabase, Ms, ForeSystem (for the Fore.NET example) system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
ModelSpace, ModelObj: IMetabaseObject;
Transf: IMsFormulaTransform;
Formula: IMsFormula;
Model: IMsModel;
Determ: IMsDeterministicTransform;
TransVar: IMsFormulaTransformVariable;
Slice: IMsFormulaTransformSlice;
TermInfo: IMsFormulaTermInfo;
Expr: IExpression;
Begin
// Get repository
Mb := MetabaseClass.Active;
// Get modeling container
ModelSpace := Mb.ItemById("MS").Bind;
// Get model
ModelObj := Mb.ItemByIdNamespace("MODEL_D", ModelSpace.Key).Edit;
Model := ModelObj As IMsModel;
// Get model calculation parameters
Transf := Model.Transform;
Formula := Transf.FormulaItem(0);
Determ := Formula.Method As IMsDeterministicTransform;
// Get the first input variable
TransVar := Transf.Inputs.Item(0);
Slice := TransVar.Slices.Item(0);
TermInfo := Transf.CreateTermInfo;
TermInfo.Slice := Slice;
// Set mode of sending variable to calculation
TermInfo.Type := MsFormulaTermType.Pointwise;
// Get model calculation expression
Expr := Determ.Expression;
Expr.References := "Ms";
// Set model calculation expression
Expr.AsString := "iif(DateSeries(MsFrequency.Annual)>=DateTime.Parse(""01.01.2018"")," + TermInfo.TermInnerText + ",0)";
// Check that expression is correct
If Expr.Valid
// If expression is correct, save model
Then ModelObj.Save;
// If expression is incorrect, display message in the console window
Else Debug.WriteLine("Model is not saved: error in equation");
End If;
End Sub UserProc;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.ForeSystem;
…
Public Shared Sub Main(Params: StartParams);
Var
Mb: IMetabase;
ModelSpace, ModelObj: IMetabaseObject;
Transf: IMsFormulaTransform;
Formula: IMsFormula;
Model: IMsModel;
Determ: IMsDeterministicTransform;
TransVar: IMsFormulaTransformVariable;
Slice: IMsFormulaTransformSlice;
TermInfo: IMsFormulaTermInfo;
Expr: IExpression;
Begin
// Get repository
Mb := Params.Metabase;
// Get modeling container
ModelSpace := Mb.ItemById["MS"].Bind();
// Get model
ModelObj := Mb.ItemByIdNamespace["MODEL_D", ModelSpace.Key].Edit();
Model := ModelObj As IMsModel;
// Get model calculation parameters
Transf := Model.Transform;
Formula := Transf.FormulaItem[0];
Determ := Formula.Method As IMsDeterministicTransform;
// Get the first input variable
TransVar := Transf.Inputs.Item[0];
Slice := TransVar.Slices.Item[0];
TermInfo := Transf.CreateTermInfo();
TermInfo.Slice := Slice;
// Set mode of sending variable to calculation
TermInfo.Type := MsFormulaTermType.mfttPointwise;
// Get model calculation expression
Expr := Determ.Expression;
Expr.References := "Ms";
// Set model calculation expression
Expr.AsString := "iif(DateSeries(MsFrequency.Annual)>=DateTime.Parse(""01.01.2018"")," + TermInfo.TermInnerText + ",0)";
// Check that expression is correct
If Expr.Valid
// If expression is correct, save model
Then ModelObj.Save();
// If expression is incorrect, display message in the console window
Else System.Diagnostics.Debug.WriteLine("Model is not saved: error in formula");
End If;
End Sub;
After executing the example, the formula is changed for the model:
The model returns zeroes if values before 2018 are used.
The model returns first factor values if values after 2018 are used.
The console displays the message about error in formula if the expression is incorrect.
Expression 1:
iif(DateSeries >= DateTime.Parse("01.01.2018"), {Brazil|BCA}, Null)
Result: the expression returns the factor observation Brazil|BCA for values on 2018.
Use: it can be used in formulas of calculated series of time series database and in formulas of attribute-based models of modeling container.
Expression 2:
iif(DateSeries = DateTime.Parse("01.01.2018"), X1, Null)
Result: the expression returns values of the X1 factor for values on 2018.
Use: it can be used in model variable-based formulas of modeling container.
See also: