Its much easier if you show a sample of your data, preferably in columns, and state your business logic clearly. Use different numbers when talking through examples with two diffent values. In your case you said the minimum amount was 45 and the amount on hand (assuming that is the current order amount?) was 45 as well, but then said you wanted to compare to half of the minimum order, so why not just start there? (22.5?)