WHERE clause in SSRS expression
Asked Answered
N

1

20

What's the syntax for inserting a WHERE clause in an SSRS expression? I am using BIDS 2008.

=Sum(Fields!QuantityToShip.Value) WHERE FIELDS!Program.Value = "FC"

The code listed above represents the logic I want to use, but obviously inserting the WHERE in there creates a syntax error.

The purpose of this expression is to define a series' value field in a stacked bar chart.

Any help would be greatly appreciated!

Novara answered 12/4, 2012 at 22:0 Comment(2)
Was my answer of any use? Did you try it?Poulard
Hi Sir Crispalot - Yes, it worked! Thanks!Novara
P
39

Use the IIF method:

=Sum(IIF(Fields!Program.Value = "FC", Fields!QuantityToShip.Value, 0))
Poulard answered 12/4, 2012 at 22:8 Comment(4)
hi, what if i have 2 fields for where clause can i just use like this: Fields!Program.Value = "FC" and Fields!Program.Value = "GC"Yaw
Well it's just a boolean expression, so you should be able to do something like: =Sum(IIF((Fields!Program.Value = "FC" And Fields!Program.OtherValue = "XX"), Fields!QuantityToShip.Value, 0)). Obviously your example won't work because Program.Value can't be FC and GC at the same time. Plus it's And in VB, not and.Poulard
How can you write an IIF depending upon the value of the intersecting column?Hyaloplasm
@Hyaloplasm not entirely sure what you mean. Perhaps try asking a new question with an example of your problem and what you've tried so far.Poulard

© 2022 - 2024 — McMap. All rights reserved.