[英]SSRS : New calculated field based on where condition
I'm new to SSRS reporting and I'm need of help... 我是SSRS报告的新手,需要帮助...
I have a dataset with fields "Process", "Level" and "Workweek" 我有一个包含“过程”,“级别”和“工作周”字段的数据集
Process Level WW ------- ----- -- Test Lvl_0 3 Test Lvl_1 28 Test Lvl_2 48 Samp Lvl_0 10 Samp Lvl_1 39 Samp Lvl_2 51
What I want now is to create two more calculated fields called Start_WW and Pro_Start that has the values from WW field. 我现在想要的是创建两个另外的计算字段,分别称为Start_WW和Pro_Start ,它们具有WW字段中的值。
WW of Lvl_0 is considered to be the Process_Start. Lvl_0的WW被视为Process_Start。
the logic is something like 逻辑就像
Process Level WW Start_WW Pro_Start ------- ----- -- -------- --------- Test Lvl_0 3 0 3 Test Lvl_1 28 3 3 Test Lvl_2 48 28 3 Samp Lvl_0 10 0 10 Samp Lvl_1 39 10 10 Samp Lvl_2 51 39 10
I know it is similar to SQL 我知道它类似于SQL
Update Table SET Start_WW=(Select WW from Table where Level='Lvl_0') where Level='Lvl_1'
更新表SET Start_WW =(从表中选择WW,其中Level ='Lvl_0')其中Level ='Lvl_1'
Update Table SET Proc_Start=(Select WW from Table where Level='Lvl_0')
更新表SET Proc_Start =(从表中选择WW,其中Level ='Lvl_0')
I'm not sure how to write the expression for it. 我不确定如何为其编写表达式。 Pls help me.
请帮助我。
Thanks in Advance!! 提前致谢!!
If the Start_WW
is simply the previous WW
then you don't even need a calculated field; 如果
Start_WW
只是先前的WW
那么您甚至不需要计算字段; you can just use the Previous()
function in the expression for the table's cell: 您可以只在表单元格的表达式中使用
Previous()
函数:
=IIF(Fields!Process.Value = Previous(Fields!Process.Value), Previous(Fields!WW.Value), 0)
For the Pro_Start
, you can add this to your SQL: 对于
Pro_Start
,可以将其添加到SQL中:
SELECT MyTable.Process, MyTable.Level, MyTable.WW, Start.Pro_Start
FROM MyTable
INNER JOIN (
SELECT Process, Level, MIN(WW) AS Pro_Start
FROM MyTable
GROUP BY Process, Level
) Start ON MyTable.Process = Start.Process AND MyTable.Level = Start.Level
With no access to the query, then you can get Pro_Start
via a Lookup() : 如果无法访问查询,则可以通过Lookup()获取
Pro_Start
:
=Lookup(Fields!Process.Value, Fields!Process.Value, Fields!WW.Value, "MyDataset")
The Lookup()
will return the first instance of the Process
and give you the WW
of that row. Lookup()
将返回Process
的第一个实例,并为您提供该行的WW
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.