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!

Pedram
  • 6,256
  • 10
  • 65
  • 87
sion_corn
  • 3,043
  • 8
  • 39
  • 65

1 Answers1

39

Use the IIF method:

=Sum(IIF(Fields!Program.Value = "FC", Fields!QuantityToShip.Value, 0))
Sir Crispalot
  • 4,792
  • 1
  • 39
  • 64
  • 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" – user1647667 Feb 19 '14 at 06:21
  • 1
    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`. – Sir Crispalot Feb 19 '14 at 08:45
  • How can you write an IIF depending upon the value of the intersecting column? – T3.0 Dec 27 '17 at 21:58
  • @T3.0 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. – Sir Crispalot Dec 28 '17 at 23:14