英文:
Passing a parameter into an MDX Query using Power Query in Excel
问题
我正在使用一个参数来构建一个MDX查询到SQL Server Cube/Tabular Model的分析服务中。这是一个示例
AnalysisServices.Database("server_name", db_param, [Query = "SELECT * FROM table_a WHERE db = 'db_name'"])
我的参数是'db_param',它可以正常工作,用于建立与服务器内正确数据库的连接,但我无法将其传递给MDX查询。我希望能够将'db_name'替换为db_param,以便调用该参数。
有什么想法吗?我尝试过单括号、双括号、放在引号内、不放在引号内。我似乎也无法创建一个链条(例如:"SELECT * FROM table_a WHERE db = " + db_param + "查询的其余部分")。
有什么想法吗?
英文:
I am using a parameter to build an MDX query to analysis services in a SQL Server Cube/Tabular Model. This is an example
AnalysisServices.Database("server_name", db_param, [Query = "SELECT * FROM table_a WHERE db = 'db_name'])
My parameter is 'db_param', and it works fine to build the connection to the right database inside the server, but I can't manage to pass it to the MDX query. I would essentially like to replace 'db_name' with db_param such that it calls the parameter.
Any ideas? I tried single brackets, double brackets, inside quotation marks, not inside quotation marks. And I can't seem to create a chain either. (e.g. "SELECT * FROM table_a WHERE db = " + db_param + "rest of the query"]
Any ideas?
答案1
得分: 1
一般情况下,您需要使用 & 而不是 + 来进行组合。
let aa = "ddd",
bb = "ccc",
statement = "SELECT * FROM " + aa + " WHERE db='" + bb + "'",
Source = [Query = statement]
in Source
英文:
In general, you need to use & not + to combine.
let aa = "ddd",
bb= "ccc",
statement = "SELECT * FROM "&aa& " WHERE db='"&bb&"'",
Source =[Query = statement]
in Source
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论