I am trying to find the time at which the measured value is half in this data table. My desired output would be a summary table with Time at half measurement by sample.

This is the summery table generated by the script and as you can see the time at half measure is not correct.

I have made the following script that uses Loc sorted to look up the values from this table but i'm having difficulty getting it to work. Are there any errors in this script? Is this the right method for what I'm looking to do and if not does anyone have any suggestions on how I can do this? one thing to note is the half value might not match a time exactly so I will be looking for the time either before of after the half measure point.
Names Default To Here(1);
Data Table( "Data" ) << Summary(
Group( :Sample, ),
Max( :Measurement ),
Freq( "None" ),
Weight( "None" )
);
New Column( "Half Max Measure", Formula (:Name("Max(Measurement)") / 2));
New Column( "Time At Half Measurement", Format ("h:m"), Formula(
dt = Data Table( "Data" );
If(dt:Sample == Sample,
Bracket = Loc Sorted( dt:Measurement << getvalues, :Half Max Measure );
dt:Time[Bracket])));