none
How to use "NOT" in an expression? RRS feed

  • Question

  • I'm writing a visibility expression and I'm getting an error. I know the expression I'm using in the IIF statement is correct. 

    =IIF(NOT IIF(WeekDay(Today()) <> 2, 
    IIF(Fields!forderdate.Value=Today() 
    OR Fields!forderdate.Value=DATEADD("d", -1, Today()),
    "**",""), 
    IIF(Fields!forderdate.Value=Today() 
    OR Fields!forderdate.Value=DATEADD("d", -1, Today()) 
    OR Fields!forderdate.Value=DATEADD("d", -2, Today())
     OR Fields!forderdate.Value=DATEADD("d", -3, Today()),
    "**","")), True,False)

    Friday, December 7, 2018 8:56 PM

All replies

  • Hi David9501

    According to your description , seems the Not syntax placed in a wrong place .

    You set the Not before the second IIF function , which the second IIF function returned the value which is not the bool type.

    So the result would change to Not “**” or Not “” ,so it caused error .

    Not syntax is not apply for the string value.

    You could use it for the boolean value like true or false .

    Assume you might like the below query:

    =Not(IIF(
     IIF( WeekDay(Today()) <> 2, 
           IIF(Fields!forderdate.Value=Today() OR Fields!forderdate.Value=DATEADD("d", -1, Today()),
                "**",
    			""), 
           IIF(Fields!forderdate.Value=Today() OR Fields!forderdate.Value=DATEADD("d", -1, Today()) OR Fields!forderdate.Value=DATEADD("d", -2, Today()) OR Fields!forderdate.Value=DATEADD("d", -3, Today()),
           "**",
    	   "")
    	   ),
    	   True,
    	   False))

    Hope it can help you.

    Best Regards,

    Eric Liu


    Best Regards, Eric Liu MSDN Community Support Please remember to click Mark as Answer if the responses that resolved your issue, and to click Unmark as Answer if not. This can be beneficial to other community members reading this thread.

    • Proposed as answer by Mitarai Queen Monday, December 17, 2018 7:11 AM
    Monday, December 10, 2018 1:42 AM
  • I'm getting the error "Input string was not in the correct format". The data type for forderdate is DateTime.
    Monday, December 10, 2018 3:17 PM
  • can I ask what your original requirement is? the expression seems to be on overcomplicated one

    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

    Monday, December 10, 2018 3:50 PM
  • can I ask what your original requirement is? the expression seems to be on overcomplicated one

    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

    The expression is to check if an order is from Today() or a previous weekday. The expression is meant to bypass counting Saturdays and Sundays.
    Monday, December 10, 2018 4:00 PM
  • can I ask what your original requirement is? the expression seems to be on overcomplicated one


    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

    The expression is to check if an order is from Today() or a previous weekday. The expression is meant to bypass counting Saturdays and Sundays.

    for that isnt it enough to just check for this?

    IF(WeekdayName(Fields!forderdate.Value) = "Sunday"
    Or WeekdayName(Fields!forderdate.Value) = "Saturday",<your logic for weekend>,<your logic for week day>)

    if you can let us know what you want to do in each case (weekend and weekday) then we can suggest full expression


    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

    • Proposed as answer by Mitarai Queen Monday, December 17, 2018 7:11 AM
    Monday, December 10, 2018 4:22 PM