Skip to main content
Participating Frequently
November 7, 2024
Question

Converting Excel Formula to Java Script

  • November 7, 2024
  • 2 replies
  • 815 views

I'm trying to convert a formula from my excel spread sheet to java script please help. I wonder if it has something to do with the LN() excel function. Based on my research Math.log is equal to LN() function in adobe. 

 

This is the native excel formula:

=((9/5)*(((237.3*(LN(((6.108*(2.718281828^((17.27*((5/9)*(B26-32)))/(237.3+((5/9)*(B26-32))))))-(0.00066*(1+0.00115*((5/9)*(B26-32)))*(((5/9)*(C26-32))-((5/9)*(B26-32)))*1013))/6.108)/17.27))/(1-(LN(((6.108*(2.718281828^((17.27*((5/9)*(B26-32)))/(237.3+((5/9)*(B26-32))))))-(0.00066*(1+0.00115*((5/9)*(B26-32)))*(((5/9)*(C26-32))-((5/9)*(B26-32)))*1013))/6.108)/17.27)))))+32

 

This is the excel formula with the cell references replaced with Field Names in adobe:

=((9/5)*(((237.3*(LN(((6.108*(2.718281828^((17.27*((5/9)*(WetBulbTempFRow1-32)))/(237.3+((5/9)*(WetBulbTempFRow1-32))))))-(0.00066*(1+0.00115*((5/9)*(WetBulbTempFRow1-32)))*(((5/9)*(AmbientTempFRow1-32))-((5/9)*(AmbientTempFRow1-32)))*1013))/6.108)/17.27))/(1-(LN(((6.108*(2.718281828^((17.27*((5/9)*(WetBulbTempFRow1-32)))/(237.3+((5/9)*(AmbientTempFRow1-32))))))-(0.00066*(1+0.00115*((5/9)*(WetBulbTempFRow1-32)))*(((5/9)*(AmbientTempFRow1-32))-((5/9)*(WetBulbTempFRow1-32)))*1013))/6.108)/17.27)))))+32

 

If the ambient temp is 72 F and the wet bulb temp is 55 F the answer should be 40 F. 

The only way i could get the formula to calculate something in adobe is by changing the LN to math.log in adobe but Its calculating the wrong number. The result ends up being 47 F instead of 40 F.

 

The adobe formula that is not working. 

((9/5)*(((237.3*(math.log(((6.108*(2.718281828^((17.27*((5/9)*(this.getField("WetBulbTempFRow1").value-32)))/(237.3+((5/9)*(this.getField("WetBulbTempFRow1").value-32))))))-(0.00066*(1+0.00115*((5/9)*(this.getField("WetBulbTempFRow1").value-32)))*(((5/9)*(this.getField("AmbientTempFRow1").value-32))-((5/9)*(this.getField("WetBulbTempFRow1").value-32)))*1013))/6.108)/17.27))/(1-(math.log(((6.108*(2.718281828^((17.27*((5/9)*(this.getField("WetBulbTempFRow1").value-32)))/(237.3+((5/9)*(this.getField("WetBulbTempFRow1").value-32))))))-(0.00066*(1+0.00115*((5/9)*(this.getField("WetBulbTempFRow1").value-32)))*(((5/9)*(this.getField("AmbientTempFRow1").value-32))-((5/9)*(this.getField("WetBulbTempFRow1").value-32)))*1013))/6.108)/17.27)))))+32

 

PLEASE HELP

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
November 7, 2024

It's Math.log(), not math.log(). Also, just saying "it doesn't work" is not very helpful. Please describe in detail what the results are: Is there an output at all? If so, is it incorrect? If not, is there an error message in the Console? What does it say? etc.

A_P_3Author
Participating Frequently
November 7, 2024

I did describe what the results are in the initial comment. 

 

"If the ambient temp is 72 F and the wet bulb temp is 55 F the answer should be 40 F. 

The only way i could get the formula to calculate something in adobe is by changing the LN to math.log in adobe but Its calculating the wrong number. The result ends up being 47 F instead of 40 F."

try67
Community Expert
Community Expert
November 7, 2024

That's not possible. Using math.log() will result in an error message, not an incorrect value.

Bernd Alheit
Community Expert
Community Expert
November 7, 2024

Add event.value= at the begin.

And change math.log to Math.log

A_P_3Author
Participating Frequently
November 7, 2024

With the changes you mentioned above, it is calculating to 31 but its suppose to be 40.  

 

This is the script based on your recommendations. 

 

event.value = ((9/5)*(((237.3*(Math.log(((6.108*(2.718281828^((17.27*((5/9)*(this.getField("WetBulbTempFRow1").value-32)))/(237.3+((5/9)*(this.getField("WetBulbTempFRow1").value-32))))))-(0.00066*(1+0.00115*((5/9)*(this.getField("WetBulbTempFRow1").value-32)))*(((5/9)*(this.getField("AmbientTempFRow1").value-32))-((5/9)*(this.getField("WetBulbTempFRow1").value-32)))*1013))/6.108)/17.27))/(1-(Math.log(((6.108*(2.718281828^((17.27*((5/9)*(this.getField("WetBulbTempFRow1").value-32)))/(237.3+((5/9)*(this.getField("WetBulbTempFRow1").value-32))))))-(0.00066*(1+0.00115*((5/9)*(this.getField("WetBulbTempFRow1").value-32)))*(((5/9)*(this.getField("AmbientTempFRow1").value-32))-((5/9)*(this.getField("WetBulbTempFRow1").value-32)))*1013))/6.108)/17.27)))))+32;