By the second expression might be a similar solution possible. It's not quite clear for me if the query on MarkerWorkFree is really needed - and if could it be simplified by multiplying the flag against the result by changing the flag from A to 1 and F to 0. A bit similar seems to me Anteil - could Anteil be greater than 1 - if not you might use: PlanECOpT * alt(Anteil, 1).
Thanks for your solution, it works. I use a Flag also. Anteil is skipped in this table, I make some calculations in the script and create a new table on a new sheet. This is less complex and for users easier to understand
But creating a new table for Anteil forced I to exclude the influence of some filters so I rebuild your solution a little (hope you don't mind):
I think on the chart-level won't be much possibilities to improve these logic but with changes on the datamodel it could be simplified and speed up - by generating a single Value-field which contained the right value regarding to each company. But this could mean a whole change of your datamodel and if it yet worked like expected I wouldn't change it only to optimize this expression.