If a skill costs magicka, spell damage and max magicka affect it's damage. If a skill costs stamina, weapon damage and max stamina affects its damage.
Ultimates are affected by the highest of your resource pools- stamina or magicka.
For most abilities, you can convert everything into a generic "power" value to see the difference between different builds. For example, with 40k magicka and 2k spell damage, your "power" is (40000 / 10) + 2000 = 6000. On a toon with 35k magicka and 2.7k spell damage, the "power" is (35000 / 10) + 2700 = 6200. So the second toon will do more damage.