Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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();
}
Solved! Go to 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.
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
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
12 | |
2 | |
2 | |
1 | |
1 |
User | Count |
---|---|
20 | |
3 | |
2 | |
2 | |
2 |