开发者

How to acess tuple/cell properties of MDX output through C#?

开发者 https://www.devze.com 2023-02-12 12:21 出处:网络
I have an MDX query I am pulling through using Adomd.net where cmd contains the command text. This, when run directly against a cube returns the following output, just a caption and the count integar

I have an MDX query I am pulling through using Adomd.net where cmd contains the command text.

This, when run directly against a cube returns the following output, just a caption and the count integar, this being a measure:

TrueCount
   n

However, how do I access this measure/tuple/number through c# ?

I know how I can get the caption, TrueCount out (see below), but I don't know how to get the blooming number out.

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

//Output the column captions from the first axis
TupleCollection tuplesOnColumns = cs.Axes[0].Set.Tuples;

foreach (var column in tuplesOnColumns)
    if (!column.Members[0].Caption.Contains("All"))
        truecount.Add(开发者_开发百科new TrueCount() { CountTitle = column.Members[0].Caption });

Any ideas or pointers greatly appreciated - apologies for the thick question.


I haven't used these functions to run MDX, but my experience with ADOMD is that the captions of rows and columns are accessed from a different object to the numbers in the middle. So I think you need to look at your cs object, and not within cs.Axes.

In ADOMD you just say myNumber = cs(x, y).FormattedValue

Hopefully that might lead you in the right direction!


You need to use the Cells property of the CellSet, Axes only gets the labels. Something like:

Count = cs.Cells[column.TupleOrdinal,0].Value

Use .FormattedValue if you want the value with the cubes formatting rules for display.

I found it easier to use cs.Axes[0].Positions rather than the tuples member.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号