NewDictionaryName: String;
NewDictionaryName: String;
The NewDictionaryName property determines the name of the dictionary to be created that is going to be used as a cube dimension.
The property is relevant if the Dictionary property is not determined, and a new dictionary is created for the cube dimension. The NewDictionaryName property is not determined by default, and the dictionary to be created has the same name as the field that it is connected with.
Executing the example requires a time series database with the DB identifier and the folder with the F_CUBES identifier, in which cubes are stored. Also, the C:\Data.xls file is required.
Sub UserProc;
Var
MB: IMetabase;
Loader: ICubeLoaderFromSource;
Provider: IDtExcelProvider;
DimBindings: ICubeLoaderDimensionBindings;
DimBinding: ICubeLoaderDimensionBinding;
FactBinding: ICubeLoaderFactBinding;
Begin
MB := MetabaseClass.Active;
//Data provider for cube
Provider := New DtExcelProvider.Create;
Provider.DriverVersion := "Excel 8.0";
Provider.File := "C:\Data.xls";
Provider.HasHeader := True;
Provider.Query := "Select * From [Sheet1$]";
Provider.Open;
//Loader of data to cube
Loader := New CubeLoaderFromSource.Create;
Loader.Database := MB.ItemById("DB").Open(Null) As IDatabaseInstance;
Loader.Parent := MB.ItemById("F_CUBES").Bind;
//Binding options for dimensions and facts
DimBindings := Loader.DimensionBindings;
DimBinding := DimBindings.Add("COUNTRY");
DimBinding.NewDictionaryName := "Countries";
DimBinding.LoadEmptyValues := True;
DimBinding.EmptyValueReplacement := "Others";
DimBinding := DimBindings.AddCalendar("DATE", DimCalendarLevel.Month);
DimBinding.NewDictionaryName := "Calendar(months)";
FactBinding := Loader.FactBindings.Add("VALUE");
FactBinding.NewElementName := "Index by country";
//Cube creation and data loading
Loader.Load(Provider, Null);
End Sub UserProc;
The import object from Excel and the cube data loader are initialized on executing the example. The dimensions bindings and facts of created cube are set up according to the information about source fields. New names will be specified for created dimensions. On loading to the countries dictionary if a country name is not specified in the file, this record will be compared with the Others element. A new standard cube, required dictionaries and dimensions and the table to store the data are created when executing the Load method. The data will be imported to the created table.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Db;
Imports Prognoz.Platform.Interop.Dt;
Imports Prognoz.Platform.Interop.Metabase;
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Loader: ICubeLoaderFromSource = New CubeLoaderFromSourceClass();
Provider: IDtExcelProvider = New DtExcelProviderClass();
DimBindings: ICubeLoaderDimensionBindings;
DimBinding: ICubeLoaderDimensionBinding;
FactBinding: ICubeLoaderFactBinding;
Begin
MB := Params.Metabase;
//Data provider for cube
Provider.DriverVersion := "Excel 8.0";
Provider.File := "C:\Data.xls";
Provider.HasHeader := True;
Provider.Query := "Select * From [Sheet1$]";
Provider.Open();
//Loader of data to cube
Loader.Database := MB.ItemById["DB"].Open(Null) As IDatabaseInstance;
Loader.Parent := MB.ItemById["F_CUBES"].Bind();
//Binding options for dimensions and facts
DimBindings := Loader.DimensionBindings;
DimBinding := DimBindings.Add("COUNTRY");
DimBinding.NewDictionaryName := "Countries";
DimBinding.LoadEmptyValues := True;
DimBinding.EmptyValueReplacement := "Others";
DimBinding := DimBindings.AddCalendar("DATE", DimCalendarLevel.dclMonth);
DimBinding.NewDictionaryName := "Calendar(months)";
FactBinding := Loader.FactBindings.Add("VALUE");
FactBinding.NewElementName := "Index by country";
//Cube creation and data loading
Loader.Load(Provider, Null);
End Sub;
See also: