DAX的参数查询

7 篇文章 0 订阅

下面的查询:

EVALUATE

CALCULATETABLE(

    'Product Subcategory',

    'Product Category'[Product Category Name] = @Category )

要注意,支持参数查询的有:

  1. OLE DB for OLAP MSOLAP driver with ADOMD.NET library
  2. OLE DB for OLAP MSOLAP driver with ADOMD library
  3. OLE DB MSOLAP driver with ADO connection
  4. XMLA Execute Command

半支持的有:

  1. Reporting Services with Analysis Services driver -支持使用DMX编辑器,而且必须手动插入参数。不支持REPORT BUILDER
  2. Reporting Services with OLE DB driver - 可以替代的连接字符为:例如,CONNECT TYPE: OLEDB CONNECT STRING: PROVIDER=MSOLAP;DATA SOURCE=LOCALHOST\TABULAR;CATALOG=ADVENTUREWORKDW;COMMAND TEXT:= "EVALUATE CALCULATETABLE(           
    'Product Subcategory',            
    'Product Category'[Product Category Name] = """ & Parameters!Category.Value & """ )"

不支持的有:

  1. OLE DB MSOLAP driver with ADO.NET connection

XMLA的例子:

<Execute xmlns="urn:schemas-microsoft-com:xml-analysis">

    <Command>

        <Statement>

            EVALUATE

            CALCULATETABLE(

            'Product Subcategory',

            'Product Category'[Product Category Name] = @Category )

        </Statement>

    </Command>

    <Properties>

        <PropertyList>

            <Catalog>AdventureWorks Tabular Model SQL 2012</Catalog>

        </PropertyList>

    </Properties>

    <Parameters>

        <Parameter>

            <Name>Category</Name>

            <Value>Bikes</Value>

        </Parameter>

    </Parameters>

</Execute> 


ADOMD使用C#的例子:

using System;using Microsoft.AnalysisServices.AdomdClient; class Program {    static void Main(string[] args) {        string connectionString =@"Provider=MSOLAP;Data Source=localhost;Catalog=AdventureWorks Tabular Model SQL 2012";        string queryString = @"EVALUATECALCULATETABLE(    VALUES('Product Subcategory'[Product Subcategory Name]),    'Product Category'[Product Category Name] = @Category )";        AdomdConnection connection = new AdomdConnection();        connection.ConnectionString = connectionString;        connection.Open();        AdomdCommand cmd = new AdomdCommand(queryString);        cmd.Parameters.Add("Category", "Bikes");        cmd.Connection = connection;        using (var reader = cmd.ExecuteReader()) {            while (reader.Read()) {                Console.WriteLine(reader[0]);            }        }    }}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值