You have to do it in the script, to create an intermediate table.
You can't save intermediate results from a sheet to use it in an other one, otherwise you have to use the same expression in the graph of the other sheet. If it is for a ratio, you can use keywords like TOTAL, ALL, etc...