in the cube it's rather simple. create a new object, add it to the cube. in the transformation use a field routine and just subtract the two dates.
if date1 - date2 > 0
result = overdue
else
result = not overdue
endif.
if you want to do it in the query you need to create formula variables (replacement path) for the two dates... check out this doc for more info Convert a Characteristic into a Key Figure (BEx)
M.