Daniel,
I think the issue here is with setting up FLAG dimension as 'Key Figure'.
Why do you want to define FLAG as 'Key Figure', especially when it's holding alpha-numeric characters (ON, OFF) ??
Try defining FLAG as a Characterstic and then use it in a condition within the FOX code.
Let us know if that works.
Cheers!