Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3933684
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:37:45+00:00 2026-05-19T23:37:45+00:00

Afternoon all. I’m building a web app and I’m attempting to pull through some

  • 0

Afternoon all.

I’m building a web app and I’m attempting to pull through some data from an SSAS cube.

I have the following MDX I would like to replicate in c# but with adding a few parameters i.e. two parameteres, one for company 123 and another for location 1:

@"SELECT NON EMPTY([Dim Unit].[All Units].[Category Group Name]) ON COLUMNS
                    FROM [Info]
                    WHERE ([Dim Company].[All Companies].&[123], 
                    [Dim Location].[All Locations].&[123]&[1])"; 

Now, I can get this up and running with one parameter:

 AdomdCommand cmdPDC = conPDC.CreateCommand();
        cmdPDC.CommandText = "SELECT [Dim Unit].[All Units].[Category Group Name].Members ON 0 FROM [Info] WHERE (StrToMember(@P1)";

        string companyid = "123";

        string sP1 = "[Dim Company].&" + company;

    cmdPDC.Parameters.Add(new AdomdParameter("P1", sP1));

But how do I then implement a second parameter, for example, if I wanted to stick a parameter in for location? I was thinking along the lines ofbelow but I can’t get the little sod to work:

AdomdCommand cmdPDC = conPDC.CreateCommand();
        cmdPDC.CommandText = "SELECT [Dim Unit].[All Units].[Category Group Name].Members ON 0 FROM [Info] WHERE (StrToMember(@P1)," + "(StrToMember(@P2))";

        string companyid = "123";
        string locationid = "1";

        string sP1 = "[Dim Company].&" + company;
        string sP2 = "[Dim Location].&" + company + "&" + location;

        cmdPDC.Parameters.Add(new AdomdParameter("P1", sP1));
        cmdPDC.Parameters.Add(new AdomdParameter("P2", sP2));

Any help or advice gratefully received.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:37:45+00:00Added an answer on May 19, 2026 at 11:37 pm

    A solution!

    AdomdCommand cmdPDC = conPDC.CreateCommand();
    cmdPDC.CommandText = "SELECT NON EMPTY [Dim Unit].[All Units].[Category Name].Members ON 0 FROM [MY CUBE] WHERE (StrToMember(@CompanyId),StrToMember(@LocationId))";
    
    string companyid = "[123]";
    string locationid = "[1]";
    
    string sCompanyId = "[Dim Company].&" + companyid;
    string sLocationId = "[Dim Location].&" + companyid + "&" + locationid;
    
    cmdPDC.Parameters.Add(new AdomdParameter("CompanyId", sCompanyId));
    cmdPDC.Parameters.Add(new AdomdParameter("LocationId", sLocationId));
    

    And a few little pointers.

    You may receive this error:

    “X parameter could not be resolved because it was referenced in an inner subexpression”

    Resolution: When inserting the @CompanyId in the quoted string, make sure the parameter is not enclosed in apostrophes (‘) – c# is clever and will convert the data type and add these apostrophes in for you. However, you won’t be able to see it in a watch window and all would appear to be fine.

    All items are returned and it would appear that your parameters are being ignored.

    Resolution: Check the very first SELECT and make sure it is SELECT NON EMPTY.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good afternoon, I wish to have a script that will look for all files
Afternoon all. I've recently been tasked with working on an event-based support ticket system,
Afternoon. Im struggling with this situation. I have a very simple tabbed content inside
Good afternoon, I've created a visual studio package that registers the Verilog language as
Good Afternoon, I am trying to use the composite filter but in vain. While
I met this weird problem, and I tried a whole afternoon to solve this,
Afternoon, Could anyone offer any advice on how to put together a program that
Afternoon, I wish to pass the row number of a table to a function
I am using Visual Source Safe 2005 and Visual Studio 2008. @#$% this Source
I am using Facebook graph API and getting its result in json format.. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.