Critical IIf/Switch condition

prasadavasare

New Member
Joined
Apr 28, 2011
Messages
45
I have a table with three fields: two Date fields [StartDate](without null values/No Blanks) and [CONVDate](with some null values/Blanks) text[Frequency] (e.g "Annual", "Quarterly", "Monthly" without null values/no blanks).


I want to create a query with an additional date field which will calculate as follows:

[CalculatedDate]: IIf([CONVDate] Is Null, IIf([Frequency]="Annual",[StartDate]+365, IIf([Frequency]="Quarterly",[StartDate]+90,IIf([Frequency]="Monthly",[StartDate]+30))),[CONVDate])


The problem is I am getting row results for only items where [CONVDate] is not null.....pls help
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
It seems to work fine foe me.
Is CONVDate declared as a Date or Text Data type?

Are you sure the values are Null?
An easy way to check is to use this expression in a calculated field:
Code:
Null Check: [CONVDate] Is Null
Does that return -1 for the CONVDate records that you think are Null?

Note, if you are looking to add EXACTLY 12, 3, or 1 month respectively, instead of adding days, you can use the DATEADD function, i.e.
Code:
CalculatedDate: IIf([CONVDate] Is Null,IIf([Frequency]="Annual",DateAdd("m",12,[StartDate]),IIf([Frequency]="Quarterly",DateAdd("m",3,[StartDate]),IIf([Frequency]="Monthly",DateAdd("m",1,[StartDate])))),[CONVDate])
 
Upvote 0
Hi Joe4,

Thank you so much for your assistance. I think I found the error. Actually the value I thought was actually not Null...rather it was ""...I changed it in query and it works fine.

Thank you so much again!!
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,580
Members
449,089
Latest member
Motoracer88

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