简体   繁体   English

表达式和求和中的Where子句

[英]Where clause in expression and sum SSRS

How can i create and expression to do the following: 我如何创建和表达以下内容:

SUM Aug-17 where Status = "Complete" 17年8月SUM,状态为“完成”

DIVIDE BY 被除以

SUM Aug-17 where Status = "UnitStarts" 17年8月SUM,其中Status =“ UnitStarts”

I have tried the following: 我尝试了以下方法:

(SUM(IFF(Fields!Status = "Complete",Fields!Aug_17)))/(SUM(IIF(Fields!Status 
= "UnitStarts",Fields!Aug_17)))

I am new to using Studio and can't seem to crack this one, as you can tell i should be coming back with a percentage. 我是使用Studio的新手,但似乎无法破解它,因为您可以告诉我应该返回一个百分比。

Thanks 谢谢

A few things you need to correct, I can't guarantee it will work after these changes as I can't test but it certainly won't work as it is so nothing to lose. 您需要纠正一些问题,由于无法测试,因此我无法保证它会在更改后起作用,但是由于没有任何损失,因此它肯定不会起作用。

1: IIF requires three arguments 1: IIF需要三个参数

IIF(<Expression to evaluate>, <Result when True>, <Result when false>)

2: When you reference a field you have to explicitly state the property you want, this is usually the Value property. 2:引用字段时,必须明确声明所需的属性,通常是Value属性。

So, your first IIF should read something like 因此,您的第一个IIF应该阅读如下内容

IFF(Fields!Status.Value = "Complete",Fields!Aug_17,0)
  1. Expressions usually start with an equals sign. 表达式通常以等号开头。
  2. (optionally) you don't need the extra parentheses around each SUM (可选)您不需要在每个SUM周围加括号

So the final expression should look something like this. 因此,最终表达式应如下所示。

=SUM(IIF(Fields!Status.Value = "Complete", Fields!Aug_17.Value, 0))
 / 
 SUM(IIF(Fields!Status.Value = "UnitStarts", Fields!Aug_17.Value, 0))

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

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