0 Replies Latest reply: Oct 15, 2015 11:22 AM by Alice Froigneux

# How to calculate an average based on the list box ?

Hello,

I created the attached line graph where I show the stock by month (one line for budget one for actual) and on the title of the graph I calculate the YTD average (for the actual and for the budget) on the title of the graph according to a variable "currentmonth" that says which is the YTD month. The expression is below:

num(sum(if([Month HFM]<=currentmonth,[Budget Stock standard]/currentmonth)),'# ##0,0')& ' M€ Avge. Actual '& num(sum([Actual Stock standard]/currentmonth),'# ##0,0')& ' M€'

When there is no selection in the "Month HFM" listbox  (which shows months 1 to 12) is done it works. But I also want people to use this listbox to show only certain months, and I want the averages in the title to adapt too. If I leave the expression as it is, it will divide the sum of the stocks of the selected month by the current month, not by the months selected in the list box showing the 12 months available.

Can anyone help me with a simple solution? I'm new to clickview.