Working on a IF & ELSE statement for a calculation. If the close date (year) is the current year, then I need to divide an amount by 3. If the close date (year) is next year, then I need to divide an amount by 5.
I wrote the following IF statement but its not working. Any ideas?
Error:
Error: Syntax error. Found 'ELSE'
Code:
IF
( YEAR(CloseDate) = YEAR(TODAY()),
(
IF( MONTH(CloseDate) = 1,
(Oil_Change_Amount_4__c / 3.1)
,
IF( MONTH(CloseDate) = 2,
(Oil_Change_Amount_4__c / 3.2)
,
IF( MONTH(CloseDate) = 3,
(Oil_Change_Amount_4__c / 3.3)
,
IF( MONTH(CloseDate) = 4,
(Oil_Change_Amount_4__c / 3.4)
,
IF( MONTH(CloseDate) = 5,
(Oil_Change_Amount_4__c / 3.5)
,
IF( MONTH(CloseDate) = 6,
(Oil_Change_Amount_4__c / 3.6)
,
IF( MONTH(CloseDate) = 7,
(Oil_Change_Amount_4__c / 3.7)
,
IF( MONTH(CloseDate) = 8,
(Oil_Change_Amount_4__c / 3.8)
,
IF( MONTH(CloseDate) = 9,
(Oil_Change_Amount_4__c / 3.9)
,
IF( MONTH(CloseDate) = 10,
(Oil_Change_Amount_4__c / 3.10)
,
IF( MONTH(CloseDate) = 11,
(Oil_Change_Amount_4__c / 3.11)
,
IF( MONTH(CloseDate) = 12,
(Oil_Change_Amount_4__c / 3.12)
)
,
ELSE IF
( YEAR(CloseDate) = YEAR(TODAY() + 1),
(
IF( MONTH(CloseDate) = 1,
(Oil_Change_Amount_4__c / 5.1)
,
IF( MONTH(CloseDate) = 2,
(Oil_Change_Amount_4__c / 5.2)
,
IF( MONTH(CloseDate) = 3,
(Oil_Change_Amount_4__c / 5.3)
,
IF( MONTH(CloseDate) = 4,
(Oil_Change_Amount_4__c / 5.4)
,
IF( MONTH(CloseDate) = 5,
(Oil_Change_Amount_4__c / 5.5)
,
IF( MONTH(CloseDate) = 6,
(Oil_Change_Amount_4__c / 5.6)
,
IF( MONTH(CloseDate) = 7,
(Oil_Change_Amount_4__c / 5.7)
,
IF( MONTH(CloseDate) = 8,
(Oil_Change_Amount_4__c / 5.8)
,
IF( MONTH(CloseDate) = 9,
(Oil_Change_Amount_4__c / 5.9)
,
IF( MONTH(CloseDate) = 10,
(Oil_Change_Amount_4__c / 5.10)
,
IF( MONTH(CloseDate) = 11,
(Oil_Change_Amount_4__c / 5.11)
,
IF( MONTH(CloseDate) = 12,
(Oil_Change_Amount_4__c / 5.12)
)
0))))))))))))