Skip to main content
Participating Frequently
Nov 7, 2024 6:59 AM UTC
Question

Converting Excel Formula to Java Script

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 is closed to new replies. Start a new post to keep the conversation going.

16 replies

try67
Community Expert
Community Expert
Nov 7, 2024 8:44 AM UTC

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.

Translate
A_P_3Author
Participating Frequently
Nov 7, 2024 3:55 PM UTC

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."

Translate
try67
Community Expert
Community Expert
Nov 7, 2024 4:12 PM UTC

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

Translate
Bernd Alheit
Community Expert
Community Expert
Nov 7, 2024 7:58 AM UTC

Add event.value= at the begin.

And change math.log to Math.log

Translate
A_P_3Author
Participating Frequently
Nov 7, 2024 3:57 PM UTC

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;

Translate