Step 1: Understanding management functions. 
  
In management, planning is the function where thinking before action takes place. It involves setting objectives, defining strategies, and preparing a course of action for achieving the goals. Planning helps in foreseeing potential problems and organizing resources effectively. 
Step 2: Analyzing the options. 
  
(A) Controlling: This is incorrect. Controlling is the process of monitoring and evaluating progress towards goals. It is performed after planning and organizing. 
  
(B) Directing: This is incorrect. Directing involves leading and motivating people to carry out the planned activities. 
  
(C) Organizing: This is incorrect. Organizing refers to arranging resources and tasks to achieve the planned objectives. 
  
(D) Planning: Correct. Planning is the function where thinking before taking action is carried out. 
Step 3: Conclusion. 
  
The correct answer is (D) Planning, as it involves thinking ahead and making decisions before taking action.