How to get the average of two columns in vie开发者_JS百科ws using lotus notes formula
Create a new column in your view to display the average. You'll add a formula to this column to calculate the average.
If the two columns you wish to average are simply based on items in your documents, then add this formula:
(Column1 + Column2) / 2
If your columns are more complex, for example they contain calculations themselves, then you'll want to refer to the column using its programmatic value. On each column, right-click on the column and then click "Column Properties". Select the last tab and set the Programmatic name to some text, for instance Calc1 and Calc2. Then use this formula in your third column:
(Calc1 + Calc2) / 2
If you want to display the average of 2 columns then Bluefoot's comment referring to another question is what you require. However, if you also want to display the result in a subsequent third column, then you have a bit more of a problem.
You will need to write a scheduled agent that takes the average but then writes the result into a field on to the document, and then use that field as the value to be displayed in the 3rd column. I say a scheduled agent as you could have this run hourly or daily as required to update values. If a user changes the values that would cause a re-calc. You can clear the new field pending update of by the scheduled agent. There are still other ways to do this, depends on requirements.
精彩评论