0

I am writing code in c# where i want to retrieve measure value and date from cube. I have written below code.

public class cubeData
{
    public void getData()
    {
        AdomdConnection con = new AdomdConnection("Data Source = <serverName>; Initial Catalog = <dbName>");
        con.Open();
        string command = @"Select [Measure].[Foo] on ROWS, [Date].AllMembers on Columns From SalesCube";
        AdomdCommand cmd = new AdomdCommand(con, command);
        AdomdDataReader dr = cmd.ExecuteReader();

        While(dr.Read())
        {
            Console.WriteLine(Convert.ToString(dr[0]);
        }
        dr.Close();
        con.Close();
    }
}

This code returns only date not measure value correspond to the date. Any suggestion would be very helpful.

Thanks in advance

2 Answers 2

1

Try using Console.WriteLine(Convert.ToString(dr[3]) to get the measure value. I'm not sure if you're using a Tabular/Multidimensional cube or what compatibility level you're at, but I'm able to access measure data from a Tabular cube at compatibility level 1200 using an MDX command that returns an equivalent result set.

Sign up to request clarification or add additional context in comments.

Comments

0

It's been a while since I've done it but you may need to flatten out the data in the resultset returned. The data could be split across different axes that you may have to iterate over.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.