1

値を取得するために、2 つ以上の軸を含む SSAS MDX クエリを作成しています。ADOMD.NET を使用して、返されたセルセットを取得し、次を使用して値を決定できます。

lblTotalGrossSales.Text = CellSet.Cells(0).Value

ADOMD.NET に返されるデータに依存する代わりに、MDX クエリで CellSet の Cell(0) 値を取得する方法はありますか?

ありがとう!


編集 1: - ダリルのコメントに基づいて、私が何をしているかについて詳しく説明します。私の現在のクエリは、次のような複数の軸を使用しています。

SELECT {[Term Date].[Date Calcs].[MTD]} ON 0, 
{[Sale Date].[YQMD].[DAY].&[20121115]} ON 1, 
{[Customer].[ID].[All].[A612Q4-35]} ON 2, 
{[Measures].[Loss]} ON 3 
FROM OUR_CUBE

Management Studio でそのクエリを実行すると、3 つ以上の軸を持つセルセットに対して結果を表示できないと言われます。ただし、ADOMD.NET を使用してこのクエリをインラインで実行し、戻り値を ADOMD.NET セルセットに読み込むと、セル "0" の値を確認して値を取得できます...それ(私はキューブの完全な初心者です)は、これらすべての値が交差する場所にある値です。

あなたの質問に答えるために、ダリル、私が欲しいのは、呼び出し元のアプリケーションに設定されたセルを読み取る必要がなく、ここで値を返す機能です。なぜあなたは尋ねることができますか?まあ..最終的には、複数の多軸クエリを実行して値を返す 1 つのクエリが欲しいと思っています。繰り返しますが..私はキューブとMDXに非常に慣れていないので、これがすべて間違っている可能性があります(私は貿易による.NET開発者です)。

4

2 に答える 2

1

クエリを単純化して 2 つの軸を返します。

SELECT {[Measures].[Loss]} ON 0, {[Term Date].[Date Calcs].[MTD] * [Sale Date].[YQMD].[DAY].&[20121115] * [Customer].[ID].[All].[A612Q4-35]} ON 1 FROM OUR_CUBE

次に、セルセットにアクセスするために次のことを試してください。

 string connectionString =  "Data Source=localhost;Catalog=AdventureWorksDW2012";
        //Create a new string builder to store the results
        System.Text.StringBuilder result = new System.Text.StringBuilder();
        AdomdConnection conn = new AdomdConnection(connectionString);
        //Connect to the local serverusing (AdomdConnection conn = new AdomdConnection("Data Source=localhost;"))
        {
            conn.Open();

            //Create a command, using this connection
            AdomdCommand cmd = conn.CreateCommand();
            cmd.CommandText = @"SELECT {  [Measures].[Unit Price]  } ON COLUMNS , {[Product].[Color].[Color].MEMBERS-[Product].[Color].[]} * [Product].[Model Name].[Model Name]ON ROWS FROM [Adventure Works] ;";

            //Execute the query, returning a cellset
            CellSet cs = cmd.ExecuteCellSet();

            //Output the column captions from the first axis//Note that this procedure assumes a single member exists per column.
            result.Append("\t\t\t");

            TupleCollection tuplesOnColumns = cs.Axes[0].Set.Tuples;

            foreach (Microsoft.AnalysisServices.AdomdClient.Tuple column in tuplesOnColumns)
            {
                result.Append(column.Members[0].Caption + "\t");

            }
            result.AppendLine();

            //Output the row captions from the second axis and cell data//Note that this procedure assumes a two-dimensional cellset
            TupleCollection tuplesOnRows = cs.Axes[1].Set.Tuples;
            for (int row = 0; row < tuplesOnRows.Count; row++)
            {
                for (int members = 0; members < tuplesOnRows[row].Members.Count; members++ )
                {
                    result.Append(tuplesOnRows[row].Members[members].Caption + "\t");
                }


                for (int col = 0; col < tuplesOnColumns.Count; col++)
                {
                    result.Append(cs.Cells[col, row].FormattedValue + "\t");
                }
                result.AppendLine();
            }
            conn.Close();

            TextBox1.Text = result.ToString();
        } // using connection

ソース : CellSet を使用したデータの取得

于 2012-11-19T15:02:52.050 に答える
-1

これは、列と行を選択するまで問題ありません。メインクエリからサブ選択クエリをトラバースする方法を分析すると役立ちます。

于 2015-08-04T02:10:10.387 に答える