Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
chrisha
Frequent Visitor

Can't read scalar values using ADOMD.NET in Analysis Services/Power BI model

Hi all, and apologies if this is the wrong forum for this.


I'm trying to connect to a local analysis services instance using ADOMD.NET. Querying for tabular data works with no problems, but I'd like to be able to execute measures stored in the model and retrieve the result.


I've tried many different variations over the same theme, but the code below represents the essentials. Trying any measure using this code will result in a generic error telling me that the "Specified method is not supported." As far as I can tell this will happen on the executeScalar call regardless of what DAX code I pass to it.


Am I doing something fundamentally wrong here, or is this a limitation of ADOMD.NET? If so, is there a way to execute DAX on the model using another framework?

 

 

using (var connection = new AdomdConnection(_connectionString))
{
  connection.Open();

  AdomdCommand cmd = new AdomdCommand(query);
  cmd.Connection = connection;

  cmd.ExecuteScalar();
  data = (string)cmd.ExecuteScalar();
}

 

 

 

1 ACCEPTED SOLUTION

Sorry, this is not a good solution as it runs SQL instead of DAX. I did find a workaround by wrapping measure-DAX in a ROW()-call so that the data would be returned as a table with one row.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

HI @chrisha,

According to your description, I think you are working with the c# programming language and try to connect the AS data source with a custom command.
If that is the case, I think you need to use the t-SQL query instead of the DAX query which you used in the connection. (As the document mention, SQL command not supported DAX expression)

SqlCommand.ExecuteScalar Method 

AdomdCommand Constructors 

using (var connection = new AdomdConnection(_connectionString))
{
	connection.Open();
	string query="SELECT * FROM TABLE";
	AdomdCommand cmd = new AdomdCommand(query);
	cmd.Connection = connection;
	cmd.ExecuteScalar();
	data = (string)cmd.ExecuteScalar();
}

Regards,

Xiaoxin Sheng

Sorry, this is not a good solution as it runs SQL instead of DAX. I did find a workaround by wrapping measure-DAX in a ROW()-call so that the data would be returned as a table with one row.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.