WHERE clause in SSRS expression

44,977

Use the IIF method:

=Sum(IIF(Fields!Program.Value = "FC", Fields!QuantityToShip.Value, 0))
Share:
44,977
sion_corn
Author by

sion_corn

Updated on July 09, 2022

Comments

  • sion_corn
    sion_corn almost 2 years

    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!

  • user1647667
    user1647667 about 10 years
    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"
  • Sir Crispalot
    Sir Crispalot about 10 years
    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.
  • T3.0
    T3.0 over 6 years
    How can you write an IIF depending upon the value of the intersecting column?
  • Sir Crispalot
    Sir Crispalot over 6 years
    @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.