[英]Adding a filter to a MDX query
I'm new to SSAS and need help with what would be equivalent to a where clause in SQL and I'm sure an easy answer for a MDX regular. 我是SSAS的新手,需要帮助的东西等同于SQL中的where子句,我确信MDX常规的答案很简单。
I have this pulling values for a multiple select parameter list in report builder but I need to filter out the contracts based on what project the user is currently viewing. 我在报表生成器中有多个选择参数列表的拉取值,但我需要根据用户当前正在查看的项目筛选出合同。 Here is the query that is pulling all the values correctly.
这是正确提取所有值的查询。
WITH MEMBER [Measures].[ParameterCaption] AS [dimContracts].[ContractName].CURRENTMEMBER.MEMBER_CAPTION
MEMBER [Measures].[ParameterValue] AS [dimContracts].[Contract Name].CURRENTMEMBER.UNIQUENAME
SELECT {[Measures].[ParameterCaption],
[Measures].[ParameterValue]} ON COLUMNS,
[dimContracts].[Contract Name].Children ON ROWS
FROM [cubeProjectEntities]
I need to add what would be equivalant to: 我需要添加等同于:
WHERE dimContracts.[Project Id] = 1
I've added which produces the correct filtered set but from here I don't know how to use the report parameter to get it to work. 我添加了哪个产生了正确的过滤集,但从这里我不知道如何使用report参数来使其工作。 Every time I test it just gives and empty dataset.
每次我测试它只是给出并清空数据集。 I have the parameter just printing on the page so I know that it is set correctly.
我的参数只是在页面上打印,所以我知道它设置正确。
WHERE [dimContracts].[Project Id].[1]
This does not work: 这不起作用:
WHERE [dimContracts].[Project Id].[@ProjectId]
And then in Report builder I will pass a parameter to the query to replace the 1 for @projectId. 然后在“报表”构建器中,我将一个参数传递给查询,以替换@projectId的1。
Thanks for any help! 谢谢你的帮助!
WITH MEMBER [Measures].[ParameterCaption] AS [dimContracts].[ContractName].CURRENTMEMBER.MEMBER_CAPTION
MEMBER [Measures].[ParameterValue] AS [dimContracts].[Contract Name].CURRENTMEMBER.UNIQUENAME
SELECT {[Measures].[ParameterCaption],
[Measures].[ParameterValue]} ON COLUMNS,
[dimContracts].[Contract Name].Children ON ROWS
FROM [cubeProjectEntities]
Where (STRTOMEMBER(@projectid))
In MDX, the where clause is a slicer. 在MDX中,where子句是一个切片器。 Here's a good article about the differences between SQL and MDX.
这是一篇关于SQL和MDX之间差异的好文章。 Here's a link about using SSRS parameters with MDX queries.
这是一个关于在MDX查询中使用SSRS参数的链接 。 You'll actually want to pass the entire member name to the query rather than just the value (ex:
[DimContracts].[Project ID].[1]
) 您实际上想要将整个成员名称传递给查询而不仅仅是值(例如:
[DimContracts].[Project ID].[1]
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.