Hi all,
I managed to retrieve relational data (from SQL Server) via FlatDataSource and to show them in a WinPivotGrid.
Yet, some attributes in my table are mis-recognised as measures: they are integer values, but aggregating them is of no use. So, these are not measures but dimensions!
It seems to me that all numeric values are considered as measures and all not-numeric values are considered as dimensions. This is just a guess, because an experimental cast to varchar for my integer attributes caused WinPivotGrid to offer them as dimensions. Back to integers, they were offered as measures...
Is there way to influence that? It should be me who decides which field is a measure and which is a dimension. :)
Thanks for any hint.
Martin
Hello Sahaja,
thanks for your enquiry.
I did some testing myself, too. I found out that there must be some connection with the explicit assignment of the "dimension role" to my mis-recognized-as-measure numeric field named MyDimensionA.
When I casted this numeric attribute explicitly to a varchar in the SQL Statement in the C# code I posted, everything worked as expected, and even very fast:
sb.AppendLine("SELECT cast([MyDimensionA] as varchar(4)) AS MyDimensionA, [MyDimensionB], [MyDimensionC], [MyMeasure] FROM TestWinPivotGrid");
Without casting, MyDimensionA remains integer and makes the waiting wheel turn infinitely when this field is dragged to the row drop area:
sb.AppendLine("SELECT [MyDimensionA], [MyDimensionB], [MyDimensionC], [MyMeasure] FROM TestWinPivotGrid");
Assigning the dimension "role" seems not to be enough. Maybe this can help investigation.
Regards
Hello Martin,
Thank you for sending us the above information. I will create a sample with this code to observe the mentioned performance issue in PivotGrid. I will provide you more information by end of Thursday.
Please let me know if you have any questions.
Sincerely,Sahaja KokkalagaddaAssociate Software Developer
thanks for your offer.
As I don't see a way to upload any files here in the forum, I'll describe how to reproduce my problem:
CREATE TABLE [dbo].[TestWinPivotGrid]
(
[ID] int,
[MyDimensionA] [varchar](2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[MyDimensionB] [smallint] NULL,
[MyDimensionC] [varchar](12) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[MyMeasure] [decimal](19, 3) NULL,
CONSTRAINT [PK_TestWinPivotGrid] PRIMARY KEY CLUSTERED
[ID] ASC
)
WITH
PAD_INDEX = OFF,
STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON
) ON [PRIMARY]
This table is filled with 200'000 rows. I can't copy them here :), but just fill them with some random data matching the data types. MyDimensionA has 365 different values, MyDimensionB has 6, MyDimensionC has 150'000.
My VS 2012 Project contains a form with a UltraPivotGrid and a OlapDataSelector. Its Code is:
using System;using System.Text;using System.Windows.Forms;using Infragistics.Olap.FlatData;using Infragistics.Olap.FlatData.Adapters.Sql;
namespace WinPivotGridDemo{ public partial class frmRelational : Form { public frmRelational() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { SetDataSource(); }
private void SetDataSource() { //http://help.infragistics.com/Help/Doc/WinForms/2016.1/CLR4.0/html/WinPivotGrid_Using_the_FlatDataSource_DataAdapter_classes.html Cursor = Cursors.WaitCursor; string connectionString = @"Data Source=myserver;Initial Catalog=mydatabase;Integrated Security=True"; StringBuilder sb = new StringBuilder(); sb.AppendLine("SELECT [MyDimensionA], [MyDimensionB], [MyDimensionC], [MyMeasure] FROM tblTestWinPivotGrid"); FlatDataSourceInitialSettings settings = new FlatDataSourceInitialSettings(); FlatDataSource ds = new FlatDataSource(settings); ds.InitializeOlapAxisElementDescriptor += ds_InitializeOlapAxisElementDescriptor; //handles decision measure/dimension, see below ds.Timeout = new TimeSpan(0,5,0); using (SqlAdapter adapter = new SqlAdapter(connectionString)) { adapter.QueryString = sb.ToString(); adapter.Fill(ds); } ultraPivotGrid1.SetDataSource(ds); olapDataSelector1.DataSource = ds; Cursor = Cursors.Default; }
//Handler for decision measure/dimension void ds_InitializeOlapAxisElementDescriptor(object sender, InitializeOlapAxisElementDescriptorEventArgs e) { switch (e.PropertyDescriptor.Name) { case "MyDimensionA": e.OlapElementDescriptor = new HierarchyDescriptor(e.PropertyDescriptor); break;
case "MyDimensionB": e.OlapElementDescriptor = new HierarchyDescriptor(e.PropertyDescriptor); break;
case "MyDimensionC": e.OlapElementDescriptor = new HierarchyDescriptor(e.PropertyDescriptor); break;
case "MyMeasure": e.OlapElementDescriptor = new MeasureDescriptor(e.PropertyDescriptor); break; } } }}
Hope you can rebuild it.
We suspect that the performance problem is in the OLAP framework, but without an actual sample we cannot tell what exactly is causing this. Please provide us a sample with this issue reproduced in it and we will further look into this issue as soon as we receive it.
Yep, it works:
//Handler
void ds_InitializeOlapAxisElementDescriptor(object sender, InitializeOlapAxisElementDescriptorEventArgs e)
{
switch (e.PropertyDescriptor.Name)
case "MyDimension":
e.OlapElementDescriptor = new HierarchyDescriptor(e.PropertyDescriptor);
break;
case "MyMeasure":
e.OlapElementDescriptor = new MeasureDescriptor(e.PropertyDescriptor);
}
Do you know any way to accelerate the row and column layouting? In my case, I've got a flat SQL Server table of ~200'000 rows; my dimension has 365 distinct values which scatter across these rows. In a database, I'd use an index, but in here....? Row buildup takes minutes...