Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2006

    Lightbulb Unanswered: using IIf with Concatination


    i have a column named type in which "buy" and "Sell" are stored along with other details in their respective columns
    i was trying to build a concatenation query in which buy should be seen as "Bought" and sell as "Sold". heres what my query looks like

    ((IIf([type]="SELL", "Sold",iff([type]="BUY", "Bought"))
    & " " & lots & " Lots"& " of " & item & " (" &security.description& ")" & " @" &price & " Closed@"&cprice ) as s

    the comma after "Sold" is creating problems i tried to replace it by & but of no use

    Can anyone help me


  2. #2
    Join Date
    Dec 2002
    Préverenges, Switzerland
    it is not the comma.
    that iff should be iif

    what happens if neither SELL nor BUY ??

    currently using SS 2008R2

  3. #3
    Join Date
    May 2004
    My immediate comment would be the incorrect number of parenthesis ((((( )))
    also im not sure if the first two are required.

    Second comment would be - if there are only two options - but and sell then you don't need to test the second iif.

    IIf([type]="SELL", "Sold", "Bought")

    Third thought would be to change the " to '

    Hope that helps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts