locked
Multiple Expressions in IIF RRS feed

  • Question

  • User265788195 posted

    How can I combine these two expressions?

    =IIF((Fields!SampleType.Value = "Fruit" & Fields!Quantity.Value > 25), "Red", "Black")
    =IIF((Fields!SampleType.Value = "Bars" & Fields!Quantity.Value > 6), "Red", "Black")

    Friday, March 1, 2013 1:28 PM

Answers

  • User281315223 posted

    You'll just need to wrap each of your conditions within a single set of parentheses and use the "Or" operator. 

    =IIF(((Fields!SampleType.Value = "Fruit" And Fields!Quantity.Value > 25) Or (Fields!SampleType.Value = "Bars" And Fields!Quantity.Value > 6)), "Red", "Black")

    This will result in "Red" if either of your two sets of conditions are met, or "Black" if neither of them are.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 1, 2013 1:32 PM

All replies

  • User281315223 posted

    You'll just need to wrap each of your conditions within a single set of parentheses and use the "Or" operator. 

    =IIF(((Fields!SampleType.Value = "Fruit" And Fields!Quantity.Value > 25) Or (Fields!SampleType.Value = "Bars" And Fields!Quantity.Value > 6)), "Red", "Black")

    This will result in "Red" if either of your two sets of conditions are met, or "Black" if neither of them are.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 1, 2013 1:32 PM
  • User265788195 posted

    Nice.. Thank you..

    Friday, March 1, 2013 2:19 PM
  • User-67082742 posted

    Hi, Another way is to use switch...it has better readability.

    =Switch( (Fields!SampleType.Value = "Fruit" & Fields!Quantity.Value >25),"Red",             (Fields!SampleType.Value = "Bars" & Fields!Quantity.Value >6) , "Red" , 1=1, "Black")

    The last one is equal to a default case.

    Monday, March 4, 2013 12:22 AM