I am installing a new exhaust fan into my bathroom. I plan to use a 2 function rocker switch to operate the fan and light independently. The power passes through the light first, and then to the switch. Can anyone provide a diagram to help me complete the circuit from the light to the switch and to the exhaust fan? Thanks!
The diagrams below show how to wire the circuit. For simplicity I have not drawn in the electrical grounding conductors (green or bare Cu wires).
Note that the 2011 NEC introduced a requirement to provide a grounded conductor at the switch location (see this answer and this outside link for more details). You can avoid this requirement if you install the circuit before January 1, 2020 but there are good reasons to follow the new code if it's not unduly burdensome. You may upgrade the switches in the future with a smart switch that requires a grounded wire. Or you may need to branch off this box in the future to run additional switched or unswitched circuits.
For a pre-2011 NEC 3-wire install the switch loop can be run using Type NM-B 14/3 with ground. Re-identify the white conductor in the switch loop cable as ungrounded (on both ends) and connect to the ungrounded conductor from the branch circuit. Then connect the black and red wires as indicated in the diagram.
For a 2011 NEC 4-wire install the switch loop could be run using Type NM-B 14/2/2 with ground. Connect the grounded (neutral) wire from the branch circuit to the white wire in the switch loop. Connect the ungrounded wire from the branch circuit to the white wire with red stripes. Connect the black and red wires as indicated in the diagram. As I write this, it is hard to find 14/2/2 cable and often more economical to run a pair of 14/3 cables. In each case we are running an grounded (neutral) wire inside the cable that has the ungrounded wires for each switch loop. This is required by code to avoid inductive heating.
Prior to 2011 NEC
After 2011 NEC