Make, Buy or Both

Having a little brain fuz as I’ve been working on this baq for a while now. But simply, I am looking to create a field in a BAQ that basically shows if the order, considering all the lines, is Make to Order, Buy to Order, or Both. Any ideas are appreciated.

Create a subquery on your BAQ for OrderRel. Display Company, OrderNum, and three calculated fields. Group By Company and OrderNum (and maybe the third calculated field (I can’t recall).

Calculated FIelds:

  1. NumMake = sum(case when OrderRel.Make = 1 then 1 else 0 end)
  2. NumBuy = sum(case when OrderRel.BuyToOrder = 1 then 1 else 0 end)
  3. OrderType = case when NumMake > 0 and NumBuy = 0 then ‘Make’ when NumMake > 0 and NumBuy > 0 then ‘Both’ when NumMake = 0 and NumBuy > 0 then ‘Buy’ else ‘’ end

Then stick this subquery in your main query and join on the Company, OrderNum columns.

1 Like