Add an extra column to DIM_DATE, WORKING_DAY_NO, to contain an ever increasing sequence number that counts the number of working days since the beginning of your calendar. WORKING_DAY_NO can be easily populated with a call to a function f_working_days(HOLIDAY_FLAG) in its mapping:
if ($HOLIDAY_FLAG='NO')
begin
$G_working_day = $G_working_day + 1;
end
return ($G_working_day);
$G_working_day is a global variable, initialised to 0.
Calculating the number of business days between ORDER_RECEIVED_DATE and ORDER_SHIPPED_DATE has become a piece of cake, now:
lookup(DIM_DATE, WORKING_DAY_NO, 0, 'PRE_LOAD_CACHE', DATE , ORDER_RECEIVED_DATE) - lookup(DIM_DATE, WORKING_DAY_NO, 0, 'PRE_LOAD_CACHE', DATE , ORDER_SHIPPED_DATE)