Finding the maximum of a column by matching another column conditionHi every one,
I have to find the maximum value in a column (:PMA Counter) after checking the condition in another column (: Condition). the condition column has "After" and "Before" characters for the different rows.
I want to pick those which are "After" and fin the maximum of (:PMA Counter) between them. I already use the below script but it is not working and only give me the Max without considering the Condition column.
dt=Current table();
dt<dt<Scripting
Re: Finding the maximum of a column by matching another column conditionThe row Select is not honored by the formula. Here is a way to handle what you need
dt << New Column( "Current PMA Counter",
Character,
Nominal,
Formula( Col Max( If( Contains( :Condition, "After" ), :PMA Counter, . ) ) )
);
Re: Finding the maximum of a column by matching another column conditionThank you very much Jim:)Re: Finding the maximum of a column by matching another column conditionCan I have the Maximum only in the rows related to "After" rows?Re: Finding the maximum of a column by matching another column conditionI do not understand what you are asking for.Re: Finding the maximum of a column by matching another column conditionI meant only those rows that had "After" in the Condition column get the Max value in the Current PMA Counter column. Other rows remain blank.Re: Finding the maximum of a column by matching another column conditionHere are a couple of versions of the formula(They are not tested). They differ in what the Col Max is based on
// 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: Finding the maximum of a column by matching another column conditionThanks, Jim
it is finding the value but for some reason does not show up in the column. THE current PMA Counter is all blank