公式 - 一年前三個季度的周平均值你好,
數據每天顯示(週一至週六)。 我已將日期轉換為星期、週、月、季度、年。
我正在嘗試獲取 2015 年 1 月 1 日至 2015 年 3 月 10 日期間的平均每週值。該值將在 2015 年 10 月 5 日顯示,並且該年剩餘時間將包含相同的值。
因此本質上,它是 Q1 - Q3 的一周平均值。
我想我可以在表格中做到這一點,但是我正在尋找一個關於如何做到這一點的公式。
任何幫助將不勝感激。
謝謝你,
回复:公式 - 一年前三個季度的周平均值絕對會做。
謝謝你的幫助回复:公式 - 一年前三個季度的周平均值我建議您使用下面的每個函數,並在腳本索引中查找它們,並研究每個函數給出的示例
幫助==>腳本索引
這是我對傳遞給你的公式的解釋
// Create a pointer to the data table so it can be referenced in the
// "Get Rows Where" function
dt = Current Data Table();
// The formula is applied to each row of the data table
// setting tYear equal to :Year sets the value of tYear to the
// Year for the current row. This is a little trick that allows
// for the "Get Rows Where" function to have something to compare to
tYear = :Year;
// For the current row, check to see if the current rows value of Date
// falls between January 1st and October 5th for the current year
If( Date MDY( 1, 1, :Year ) >= :date <= Date MDY( 10, 5, :Year ),
// If it is in between those dates then calculate the Mean of
// the column for Value where all the rows where Week is equal
// to the current row's value of week, and where all the rows where
// Year is equal to the current rows value of year
temp = Col Mean( :Value, :Week, :Year )
,
// If the current row's date isn't between the dates above, then
// find all of the rows where Week is equal to week 39, and year is
// equal to the row;'s current year. Then find the mean of those values
temp = Mean( :Value[dt << get rows where( :Week == 39 & tYear == :Year )] )
);
// The value that JMP returns to a formula is the last value exeuted in the formula
// Therefore, by placing the variable "temp" as the last thing seen, the
// calculated value of temp is what the formula value is
temp;回复:公式 - 一年前三個季度的周平均值你好,
我對 Jmp 及其語言很陌生。 如果您不介意我問,請您引導我完成您列出的公式。
公式起作用並產生了它需要產生的東西,但我試圖用英語理解它。
再次感謝您的幫助
回复:公式 - 一年前三個季度的周平均值謝謝你,
結果與我想要的略有不同(我得到了每周平均值與從 Q1-Q3 的所有周的平均值),然後我意識到公式產生的結果實際上正是我需要的。我原來的問題應該改變。
我很感謝你在這件事上的幫助。
非常感謝。
你節省了我很多時間
回复:公式 - 一年前三個季度的周平均值這是一個我相信會起作用的腳本......我真的沒有測試它,但我想你會看到這個概念。我唯一的猜測是 10 月 5 日是工作週。
dt = Current Data Table();
tYear = :Year;
If( Date MDY( 1, 1, :Year ) >= :date <= Date MDY( 10, 5, :Year ),
temp = Col Mean( :Value, :Week, :Year ),
temp = Mean( :Value[dt << get rows where( :Week == 39 & tYear == :Year )] )
);
temp;
回复:公式 - 一年前三個季度的周平均值抱歉,我忘了提及,在新的一年開始時,我的價值將為 0,直到第四季度到來,然後使用該年的新數據集重複該過程。
謝謝