powerquery automation

How to Count Monthly Leave Days Automatically in Excel Power Query

minbe-data 2026. 4. 6. 21:27

In Excel, employee leave dates are often stored across multiple columns such as Leave1, Leave2, Leave3, and so on.

The problem is that we may need to count how many leave days each employee used in a specific month.

With Power Query, this can be automated easily.

In this example, the main data table is named Table1, and the target month is stored in a separate named range called TargetMonth.

Power Query checks all leave date columns, compares each date with the selected target month, and returns the number of matching leave days in a new column called MonthlyLeaveUsed.

This method is useful because when new leave dates are added or the target month is changed, the result can be updated simply by clicking Refresh.In Excel, employee leave dates are often stored across multiple columns such as Leave1, Leave2, Leave3, and so on.

The problem is that we may need to count how many leave days each employee used in a specific month.

With Power Query, this can be automated easily.

In this example, the main data table is named Table1, and the target month is stored in a separate named range called TargetMonth.

Power Query checks all leave date columns, compares each date with the selected target month, and returns the number of matching leave days in a new column called MonthlyLeaveUsed.

This method is useful because when new leave dates are added or the target month is changed, the result can be updated simply by clicking Refresh.

 

 

videolink - https://youtu.be/Dkn08M7dI2A

 

Download the sample file below.

You can download the zip file in [Download] page

The file name is 11.monthly_leave_count.zip

Use the English M code provided for your dataset.

✔ Download the ready-to-use Power Query template below  
✔ Just copy and paste the M code – works instantly

You may need to manipulate the M code under your circumstance. You consider this point and use M code.

 

below txt file is detailed-explanation. You use M code in reference with this explanation.

 

explanation.txt
0.00MB

 

------------------------------------------------------------------

Need a custom automation for your Excel workflow?

I can build a tailored solution based on your data.

✔ Used in real-world business automation  
✔ Saves hours of manual work

minbedata@gmail.com

You can pay via PayPal.

You can also contact me via Upwork for secure payment and project handling.

<a href="https://www.upwork.com/freelancers/~01eb52dbd212cffc17" target="_blank">
Hire me on Upwork
</a>

You don't worry about conversing with me.

My Major is an English literature, so I can speak English fluently and read, listening, writing proficiently

korean version web address (한국버전) is 

<a href="https://blog.naver.com/minbe-data" target="_blank">네이버 블로그 바로가기</a>