通過匹配另一個列條件來查找一列的最大值嗨,大家好,
在檢查另一列(:條件)中的條件後,我必須在列(:PMA計數器)中找到最大值。條件列的不同行具有“ After”和“ Before”字符。
我想選擇“之後”的那些,並在它們之間尋找最大的(:PMA Counter)。 我已經使用了下面的腳本,但是它不起作用,只給我Max而不考慮Condition列。
dt =當前表();
dt <<選擇Where(包含(:Condition,“ After”));
dt <<新列(“當前PMA計數器”,字符,標稱,公式(Col Max(:PMA計數器)));
腳本編寫回复:通過匹配另一個列條件來查找一列的最大值公式不支持“選擇”行。 這是一種處理您所需要的方法
dt << New Column( "Current PMA Counter",
Character,
Nominal,
Formula( Col Max( If( Contains( :Condition, "After" ), :PMA Counter, . ) ) )
);
回复:通過匹配另一個列條件來查找一列的最大值非常感謝吉姆:)回复:通過匹配另一個列條件來查找一列的最大值我可以僅在與“之後”行相關的行中具有“最大值”嗎?回复:通過匹配另一個列條件來查找一列的最大值我不明白您的要求。回复:通過匹配另一個列條件來查找一列的最大值我的意思是,只有在“條件”列中具有“之後”的行才能在“當前PMA計數器”列中獲得“最大值”。其他行保持空白。回复:通過匹配另一個列條件來查找一列的最大值這是公式的幾個版本(未經測試)。 它們在Col Max的基礎上有所不同
// formula where col max is based upon only rows with "After" in PMA Counter
// and the Col Max only appears in rows where PMA Counter has "After" in it
dt << New Column( "Current PMA Counter",
Character,
Nominal,
Formula(
If( Row() == 1,
x = Col Max( If( Contains( :Condition, "After" ), :PMA Counter, . ) )
);
If( Contains( :Condition, "After" ),
y = x,
y = .
);
y;
)
);
// formula where col max is based upon all rows
// and the Col Max only appears in rows where PMA Counter has "After" in it
dt << New Column( "Current PMA Counter",
Character,
Nominal,
Formula(
If( Row() == 1,
x = Col Max( :PMA Counter )
);
If( Contains( :Condition, "After" ),
y = x,
y = .
);
y;
)
);
Re:通過匹配另一個列條件來查找一列的最大值謝謝,吉姆
它正在查找該值,但由於某種原因未在該列中顯示。當前的PMA計數器全為空白