本文介绍了SSRS:基于 where 条件的新计算字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 SSRS 报告的新手,需要帮助...

I'm new to SSRS reporting and I'm need of help...

我有一个包含流程"、级别"字段的数据集和工作周"

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

我现在想要创建另外两个名为 Start_WWPro_Start 的计算字段,它们具有来自 WW 字段的值.

What I want now is to create two more calculated fields called Start_WW and Pro_Start that has the values from WW field.

Lvl_0 的 WW 被认为是 Process_Start.

WW of Lvl_0 is considered to be the Process_Start.

逻辑有点像

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

我知道它类似于 SQL

I know it is similar to SQL

Update Table SET Start_WW=(Select WW from Table where Level='Lvl_0') where Level='Lvl_1'

Update Table SET Proc_Start=(Select WW from Table where Level='Lvl_0')

Update Table SET Proc_Start=(Select WW from Table where Level='Lvl_0')

我不知道如何为它写表达式.请帮助我.

I'm not sure how to write the expression for it. Pls help me.

提前致谢!!

推荐答案

如果 Start_WW 只是之前的 WW 那么你甚至不需要计算字段;您可以在表格单元格的表达式中使用 Previous() 函数:

If the Start_WW is simply the previous WW then you don't even need a calculated field; you can just use the Previous() function in the expression for the table's cell:

=IIF(Fields!Process.Value = Previous(Fields!Process.Value), Previous(Fields!WW.Value), 0)

对于 Pro_Start,您可以将其添加到您的 SQL:

For the Pro_Start, you can add this to your 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

在无法访问查询的情况下,您可以通过 Pro_Start="nofollow">查找():

With no access to the query, then you can get Pro_Start via a Lookup():

=Lookup(Fields!Process.Value, Fields!Process.Value, Fields!WW.Value, "MyDataset")

Lookup() 将返回 Process 的第一个实例,并为您提供该行的 WW.

The Lookup() will return the first instance of the Process and give you the WW of that row.

这篇关于SSRS:基于 where 条件的新计算字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-04 06:50