Compute Column Mean while restricting observations used
Hello,
I want to get a column mean into a new column but I want to be able to restrict the date range that I use. I want to be able to say get column mean from day x to day y in my formula. This is the current formula that i have:
New Column ("X",
Numeric,
Continuous,
Format ("Best", 12),
Formula (Col Mean (:WeeklyPercent, :Week, :Source)), Set Selected);
It pull the average weekly percent by week and source of the data which is perfect, however, even when I put a data filter on the dataset it still pulls the mean for the entire data set by those two by variables. I want to be able to change the date range that those column means are from. Can anyone help me with that?
Thanks.
Re: Column Mean using only part of the dataset<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />The column functions operate on the whole table, ignoring selection and exclusions. However, you can make a formula column that's dependent on the row state and use that column as a BY variable.
New Column( "mysel", Formula( Selected( Row State() ) ) );
New Column( "meany", Formula( Col Mean( :y, :mysel) ) );
If you're using the global data filter with selection turned on, the Column Means will be recomputed whenever the selection changes.