+ Start a Discussion
Developer BaseDeveloper Base 

Currency formula does not work

My formula counts the number of months between two dates and by divides a currency field by that number to get an average/month result.

What works:

Currency field
Fee__c

Number of months between two dates
((YEAR(EndDate__c) - YEAR(StartDate__c ))*12) + (MONTH(EndDate__c) - MONTH(StartDate__c ))

What does not work and needs to work:

Currency field divided by number of months between two dates
(Fee__c / ((YEAR(EndDate__c) - YEAR(StartDate__c ))*12) + (MONTH(EndDate__c) - MONTH(StartDate__c )))

My last formula does not compute anything - the field remains blank. Why is that? How to solve that?
 
PriyaPriya (Salesforce Developers) 

Hi 

It will not work because the Data Type for Field Fee is Currenccy which is incompatiable with data type number (returned value after calculating the number of months).

Use a formula that goes from currency to text, and then to number.   E.g.  VALUE(TEXT([Account].AnnualRevenue)) 

If this helps, please mark it as best answer.

Regards,

Priya Ranjan

Suraj Tripathi 47Suraj Tripathi 47
Hi Developer Base,

If your field is blank then in that field data is not generating you can apply 
system.debug() after every line to get a reason about why this field is blank. 

If you find your Solution then mark this as the best answer.
  
Thank you!
Regards,
Suraj Tripathi