Fields: ICubeCreatorFields;
Fields: Prognoz.Platform.Interop.Cubes.ICubeCreatorFields;
The Fields property returns the collection of source field bindings to dimension attributes.
The property is used if it is required to bind several source fields to several attributes of one dimension.
Executing the example requires the C:\Data.xls file that contains data by countries. The data is located in columns named Country ISO, Country Name, Date and Value, the data has monthly frequency. Any other columns containing data can be present. The repository must have a folder with the F_Cubes identifier.
Sub UserProc;
Var
MB: IMetabase;
Loader: ICubeLoaderFromSource;
Provider: IDtExcelProvider;
Bindings: ICubeLoaderDimensionBindings;
Binding: ICubeLoaderDimensionBinding;
Fields: ICubeCreatorFields;
Field: ICubeCreatorField;
FactBindings: ICubeLoaderFactBindings;
FactBinding: ICubeLoaderFactBinding;
Begin
MB := MetabaseClass.Active;
//Data source for cube
Provider := New DtExcelProvider.Create;
Provider.DriverVersion := "Excel 8.0";
Provider.File := "C:\Data.xls";
Provider.HasHeader := True;
Provider.Query := "Select * From [Sheet1$]";
//Data loader to cube
Loader := New CubeLoaderFromSource.Create;
Loader.Parent := MB.ItemById("F_CUBES").Bind;
Loader.LoadDuplicates := True;
//Set up bindings of dimensions and facts
Bindings := Loader.DimensionBindings;
Binding := Bindings.Add("Country ISO");
Binding.AttributeId := "ISO";
//Bind the second attribute to dimension
Fields := Binding.Fields;
Field := Fields.Add("Country Name");
Field.AttributeId := "Name";
Field.DataType := DbDataType.String;
Field.Identifying := True;
//Calendar
Binding := Bindings.AddCalendar("Date", DimCalendarLevel.Month);
//Facts binding
FactBindings := Loader.FactBindings;
FactBinding := FactBindings.Add("Value");
FactBinding.CubeFactAggregationType := CubeFactBindingAggregationType.Sum;
//Create cube and load data
Loader.Load(Provider, Null);
End Sub UserProc;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.Dimensions;
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();
Bindings: ICubeLoaderDimensionBindings;
Binding: ICubeLoaderDimensionBinding;
Fields: ICubeCreatorFields;
Field: ICubeCreatorField;
FactBindings: ICubeLoaderFactBindings;
FactBinding: ICubeLoaderFactBinding;
Begin
MB := Params.Metabase;
//Data source for cube
Provider.DriverVersion := "Excel 8.0";
Provider.File := "C:\Data.xls";
Provider.HasHeader := True;
Provider.Query := "Select * From [Sheet1$]";
//Data loader to cube
Loader.Parent := MB.ItemById("F_CUBES").Bind;
Loader.LoadDuplicates := True;
//Set up bindings of dimensions and facts
Bindings := Loader.DimensionBindings;
Binding := Bindings.Add("Country ISO");
Binding.AttributeId := "ISO";
Fields := Binding.Fields;
//Bind the second attribute to dimension
Field := Fields.Add("Country Name");
Field.AttributeId := "Name";
Field.DataType := DbDataType.ddtString;
Field.Identifying := True;
//Calendar
Binding := Bindings.AddCalendar("Date", DimCalendarLevel.dclMonth);
//Facts binding
FactBindings := Loader.FactBindings;
FactBinding := FactBindings.Add("Value");
FactBinding.CubeFactAggregationType := CubeFactBindingAggregationType.cfbatSum;
//Create cube and load data
Loader.Load(Provider, Null);
End Sub;
The import object from Excel and the cube data loader are initialized on executing the example. Bindings of dimensions and facts of created cube are set up. Aggregation is set up for the fact. Data of two source fields is loaded to the dimension by countries. A new standard cube, required dictionaries and dimensions and the table to store the data are created on executing the Load method. The data will be imported to the created table.
See also: