Skip to main content
RSS feed Subscribe to feed

 

Transformation: New Data Table and Show UI

This custom transformation creates a new data table where the data is transformed and the UI needs to be shown.

In this example the same operation as in Transformation: Creating a New Data Table is perform, but in this case we do not set any settings on the transformations added and use the prompting inside the transformation to display the user interfaces instead

AnalysisApplication app = this.Context.GetService<AnalysisApplication>();

// create the data source.
DataSource ds = app.Document.Data.CreateFileDataSource("c:\\test.txt");

DataFlowBuilder dfb = new DataFlowBuilder(
    ds,
    app.ImportContext);

// add the transformation.
dfb.AddTransformation(
    new PivotTransformation());

// show the pivot prompt UI, the execute step is not really nessecary 
// since all needed UI:s will be shown when the table is created.
// but can be useful to control when the UI should be shown.
dfb.Execute(1, DataSourcePromptMode.RequiredOnly);

// add an unpivot transformation after
dfb.AddTransformation(
    new UnpivotTransformation());

// show the unpivot prompt UI
dfb.Execute(2, DataSourcePromptMode.RequiredOnly);

// create the flow
DataFlow flow = dfb.Build();

// create a new table from the flow.
DataTable newTable = app.Document.Data.Tables.Add(flow.DocumentTitle, flow);