4 way IIF with nulls?

exceliz

Board Regular
Joined
Sep 26, 2007
Messages
154
Hi experts..

I cannot get my iif statement to work in access query; its driving me mad, just cant seem to grasp the nulls I think.

I need to calculated a waiting time with adjustments, I have a field called RTT which is the current wait in days without adjustments.
I have a field called total suspension which is the number of days to deduct from RTT if populated, and if there is a DNA Date I need to work out the RTT from DNA date to todays date to give the new RTT days waiting....But they could both apply, or just one apply or non apply?

this is what i had but doesnt work for all IIFs: ive switched them around and tried isnull etc
RTTdADJ:
IIf([DNADate] Is Not Null,DateDiff("d",[DNADate],Date()),IIf([DNADate] And [Total Suspension] Is Null,[RTT],IIf([DNADate] And [Total Suspension] Is Not Null,(DateDiff("d",[DNADate],Date()))-[Total Suspension],[RTT]-[Total Suspension])))

thank you for any advice on this one :) i will keep trying in the mean time
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I think you may have a Syntax issue.

Look at this part here:
Code:
[COLOR=#333333]IIf([DNADate] And [Total Suspension] Is Null[/COLOR]
Are you trying to check to see if BOTH are Null? If so, you need to write it like this:
Code:
[COLOR=#333333]IIf([DNADate] [/COLOR][COLOR=#ff0000]Is Null[/COLOR][COLOR=#333333] And [Total Suspension] Is Null[/COLOR]
Otherwise, your code is just checking to see if a value for DNADate exists (not if it is null).
 
Upvote 0
thanks, i have managed to re do it and it works!! - it was all about the nulls. Total suspension was only populated if you had a suspension.
IIf(IsDate([DNADate]),DateDiff("d",[DNADate],Date())-IIf([Total Suspension] Is Null,0,[Total Suspension]),IIf([Total Suspension] Is Not Null,[RTT]-[Total Suspension],[RTT]))
 
Upvote 0

Forum statistics

Threads
1,214,786
Messages
6,121,553
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top