I am trying to get something to work on a form i am building for my job and it doesn’t seem to be working the way i expect it to.
I want to calculate the percent difference between the two fields ANL_CMA1_NUM_CLOSED_SALES and ANL_CMA2_NUM_CLOSED_SALES.
I thought my math was correct but i am only getting results in single digits, either positive or negative depending on the inputted values.
I am working on a form where i can customize permission level and rounding, and i am rounding this to the nearest hundredth. Can anyone help me with this one?
The original formula did not have the -100) * 100) portion at the end of it but also did not work properly.
FormSet.SetFieldValue(CurrentForm, "ANL_CHG_NUM_CLOSED_SALES",
(((FormSet.GetFieldValue(CurrentForm, "ANL_CMA2_NUM_CLOSED_SALES") -
FormSet.GetFieldValue(CurrentForm, "ANL_CMA1_NUM_CLOSED_SALES")) /
FormSet.GetFieldValue(CurrentForm, "ANL_CMA1_NUM_CLOSED_SALES")) -100) * 100)
You may be using integer division (ie, 1/3 == 0) where you need floating-point division (ie 1./3 == 0.3333333).
It may also be easier to understand if you break it up a bit –