Well your formula worked, so you could use that. I agree that formula is a difficult one to maintain.
Here is an alternative, add a script to the table. I added the JSL (after the wait(5) ) that shows how to change the quantile and threshold and run the script. Or interactively, change the 2 variables and click on Update D1.
Use whichever method you find easiest for you to use.
//Create Table Variable
dt = currentdatatable();
dt << Set Table Variable( "Quantile", 0.9 );
dt << Set Table Variable( "Threshold", 1 );
dt << New Column("D1", Numeric, Continuous);
dt << New Script ("Update D1",
dt = current data table();
_xx = dt << get rows where(:P1 ==0 & :P2 <:Threshold);
dt << Set Table Variable("QQ", Quantile(dt:Quantile, dt:D0[_xx] ));
qq = Quantile(dt:Quantile, dt:D0[_xx] );
//caption(char(qq)); wait(2); caption(remove); //uncomment to test
dt:D1 << Set Each Value(
If(:P1 ==0 & :P2 <:Threshold & :D0< qq, :D0, empty())
);
);
wait(5);
dt << Set Table Variable( "Quantile", 0.6 );
dt << Set Table Variable( "Threshold", 1.8 );
dt << Run Script("Update D1") ;