Thank you for your reply. I had some trouble explaining what I'm trying to do.
My core problem is that I don't want to have all figures stored in fact_data. Only the "basic" figures should be stored there. All other figures should automatically be computed by MySQL using the "basic" figures in fact_data and figure-specific computation rules.
Therefore your suggestion to use this query...
SELECT year_id, location_id, figure_id, value
FROM fact_data -- ###MAGIC###
WHERE figure_id IN ("total_costs", "purchase_costs", "goods_costs")
AND year_id = 2010;
...would only return the information for goods_costs as this is the only basic figure that MySQL could find there.
With the UNION query from my original post I wanted to give an example of a query that could kind of "dynamically create" the necessary figures on the fly. However, such an UNION query is not performant at all and also hard to maintain - that's why I'm looking for a suitable alternative.
Is this more helpful to understand my problem? Should I give you any more details of what I'm trying to do?