简体   繁体   English

ssrs中切换的不同数据集

[英]different dataset in switch in ssrs

I have 2 datasets in a single report, out of the 5 columns 2 are derived from dataset1 and 3 from dataset2 (dataset 2 being the primary dataset). 我在一个报告中有2个数据集,5个列中的2个来自数据集1,3个来自数据集2(数据集2是主要数据集)。 Now when I try to use the below switch command,it does not give me any error but doesn't show any results. 现在,当我尝试使用下面的switch命令时,它不会给我任何错误,但不会显示任何结果。 The dataset1 is a share point list. dataset1是共享点列表。

=SWITCH(First(Fields!xyz.Value, "dataset1")="Platinum",25,First(Fields!xyz.Value, "dataset1")="",0,First(Fields!xyz.Value, "dataset1")="Gold",15)

All the other columns in the tablix are from dataset2 and the report runs fine just no data comes in this column Tablix中的所有其他列都来自dataset2,报告运行正常,此列中没有数据

The First() expression is probably the problem, and the reason it's working when you change the IIF condition. First()表达式可能是问题,以及更改IIF条件时它的工作原因。 First() just literally fetches the first value in the named field from the target dataset, so if it's not "Platinum", an empty string or "Gold" it will just return nothing. First()只是从目标数据集中获取命名字段中的第一个值,因此如果它不是“Platinum”,则为空字符串或“Gold”,它将不返回任何内容。 On the otherhand, if the first value of abc is 1 or 3 it will always return "Platinum" or "Gold" 另一方面,如果abc的第一个值是1或3,它将始终返回“Platinum”或“Gold”

It's important to realise this will return exactly the same data on every single row of the table, since you're only ever looking at the FIRST row of dataset1. 重要的是要意识到这将在表的每一行返回完全相同的数据,因为您只是在查看数据集1的第一行。

I think you're probably after the LookUp() function, which will use primary keys to match the datasets and fetch different data from dataset1 depending on the data in the current row of dataset2. 我想你可能是在LookUp()函数之后,它将使用主键来匹配数据集,并根据数据集2的当前行中的数据从数据集1中获取不同的数据。

Hope that sort of makes sense? 希望那有道理吗?

EDIT IN REPLY TO COMMENT: 编辑回复评论:

You can do this in two ways then. 你可以用两种方式做到这一点。 You can either use the same LookUp() formula that you use to populate the column in your switch statement to get the points, for example; 例如,您可以使用相同的LookUp()公式来填充switch语句中的列以获取点;

=Switch(LookUp(Fields!application_name.Value, Fields!application_name.Value, Fields!service_level.Value, "dataset1") = "Platinum", 25, LookUp(Fields!application_name.Value, Fields!application_name.Value, Fields!service_level.Value, "dataset1") = "Gold", 15)

Secondly, you can refer directly to the column that is already fetching "Gold" or "Platinum". 其次,您可以直接引用已经获取“Gold”或“Platinum”的列。 For example if that textbox is called Textbox10 (check the top right of the properties panel to see the name) then you can use: 例如,如果该文本框被称为Textbox10(检查属性面板的右上角以查看名称),那么您可以使用:

=Switch(ReportItems!Textbox10.Value = "Platinum", 25, ReportItems!Textbox10.Value = "Gold", 15)

Either method should work fine. 两种方法都应该正常工作。 Basically what you're doing there is ensuring you always check the right service level for that application rather than just the first one in dataset1 基本上你在那里做的是确保你总是检查该应用程序的正确服务级别,而不仅仅是数据集1中的第一个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM