There isn't actually a straightforward "cash in, cash out" expression that you can use to describe the profitability of a colony. Although defense/administration was the responsibility of the metropole, most wealth and economic activity was generated by trading of private companies with the colonies, such as mineral extraction, shipping lines, and dumping finished goods. As a result the question of who is profiting from said colony and by how much becomes much more difficult to answer, especially because a lot of these 19th century companies were rather unscrupulous about record keeping. In the long run though these colonies were generally profitable for the ruling class, who got all the benefits of monopolistic trade while the state fronted the associated costs of administration, defense, etc. So in the expression "State investment into colony ~ Wealth generated from colony" the left side is pretty easy to get given some constraints, but the right side isn't so easy.
TL;DR the whole "X colony was profitable" and "Y wasn't" isn't that simple of a statement