question

DTJG avatar image
DTJG asked

Multiple IF and OR Statements in an expression.

I am trying to simply clear a field given a few conditions. If the date falls in the 3 days, yesterday, today and tomorrow, AND the record has a certain LOC value and a specific OrdStatusDesc value. Below is what I have and oddly enough it runs without error but it does not remove the dates at all.

=IIF((Fields!promise_dt.Value = dateadd(dateinterval.Day,+ 1,Today())) or

(Fields!promise_dt.Value = dateadd(dateinterval.Day,- 1,Today())) or

(Fields!promise_dt.Value = dateadd(dateinterval.Day,+0,Today())) OR

(Fields!loc.Value = "MOD") OR

(Fields!OrdStatusDesc.Value = "Pick Ticket Printed")

,Fields!promise_dt.Value,"")

ssrs-2008reportingvisual-studio-2010
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ppickup avatar image
ppickup answered

Not sure I understand your question, but if you want to clear the fields if your conditions are true, then the last two expressions are in the wrong order:

=IIF((Fields!promise_dt.Value = dateadd(dateinterval.Day,+ 1,Today())) or

(Fields!promise_dt.Value = dateadd(dateinterval.Day,- 1,Today())) or

(Fields!promise_dt.Value = Today()) OR

(Fields!loc.Value = "MOD") OR

(Fields!OrdStatusDesc.Value = "Pick Ticket Printed")

,"" ,Fields!promise_dt.Value)


Also, there is not much point in adding 0 to today() so I simplified the equation a bit.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

DTJG avatar image
DTJG answered

Sorry if I am not explaining myself very good. I have 2 statements that work independent of each other, the "Ask" is to have them work together, so that if either date statement is true, leave the date, if its not true and the date is not today or tomorrow, replace the date field information and input TBD. As I say, each of these statements work independent of each other.

This image is an example of what I am going for. (Todays date is 5/19/2022) so all I am trying to do is leave the dates of Today and Tomorrow in tact and replace all other dates with TBD.

promise-date-example.jpg.


Works Today Only Independently

=IIF(Fields!promise_dt.Value <> Today(), "TBD", Fields!promise_dt.Value)

Above leaves only today's date and all other blocks read TBD. (The problem is I want the second statement to work before any changes are made)

Works for Tomorrow Only Independently

=IIF(Fields!promise_dt.Value <> DateAdd("d",1,Today()), "TBD", Fields!promise_dt.Value)

Thank you so much for even taking time to review this.



10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

DTJG avatar image
DTJG answered

Faux Crisis Adverted.. I found the solution.. thanks for any that even thought about this.

=IIF(((Fields!promise_dt.Value = Today())) or (Fields!promise_dt.Value = DateAdd("d",+1,Today())) ,Fields!promise_dt.Value,"TBD")

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.