🇹🇭 Power Query ขั้นตอนละเอียด แก้ไฟล์ Payroll ยังไงให้ใช้งานได้จริง
สรุปจากคลิปของช่อง Lin Davoy คลิปนี้เป็นเคสจริงที่คนทำงานสาย HR และ Data สายจ่ายเงินเดือนต้องเจอบ่อยมาก คือไฟล์ Payroll ที่ export ออกมาจากระบบเงินเดือน มักจะมีหน้าตาไม่พร้อมใช้งานทันที มีทั้งหัวตารางซ้อนกันหลายชั้น มีแถวรวมยอด (subtotal) แทรกอยู่กลางตาราง หรือบางคอลัมน์เก็บข้อมูลเป็นข้อความทั้งที่ควรจะเป็นตัวเลข Lin เลยพาไล่ทำความสะอาดไฟล์แบบนี้ด้วย Power Query ทีละขั้นตอนแบบละเอียด เพื่อให้เอาไปใช้ต่อกับการวิเคราะห์หรือทำ Dashboard ได้จริง
ทำไมไฟล์ Payroll ถึงต้องผ่าน Power Query ก่อนเสมอ
ไฟล์เงินเดือนที่ export จากระบบ HR ส่วนใหญ่ถูกออกแบบมาให้ “คนอ่าน” ไม่ใช่ให้ “โปรแกรมอ่าน” จึงมักมีปัญหาซ้ำๆ กันแทบทุกบริษัท เช่น แถวหัวตารางไม่ได้อยู่แถวแรก มีแถวว่างคั่นระหว่างแผนก มีการรวมยอด (merge cell) ในบางคอลัมน์ หรือชื่อพนักงานกับรหัสพนักงานอยู่ในเซลล์เดียวกัน ถ้าเอาไฟล์แบบนี้ไปทำ Pivot Table หรือสร้างกราฟตรงๆ มักจะได้ผลลัพธ์ที่ผิดเพี้ยน Power Query จึงเป็นเครื่องมือที่เหมาะที่สุดในการแปลงไฟล์แบบนี้ให้เป็นตารางที่ “เครื่องอ่านได้” ก่อนนำไปใช้งานต่อ
ขั้นตอนหลักในการทำความสะอาดไฟล์ Payroll
ในคลิป Lin ไล่ให้ดูทีละขั้นตอนอย่างละเอียด เริ่มจากการโหลดไฟล์เข้า Power Query Editor แล้วจัดการเรื่องหัวตาราง (Promote Headers) ให้ถูกแถว ตามด้วยการลบแถวที่ไม่จำเป็นออก เช่น แถวหัวเรื่องรายงาน แถวว่าง หรือแถวสรุปยอดรวมที่ปนอยู่กลางข้อมูล จากนั้นจึงจัดการคอลัมน์ที่ข้อมูลปนกัน เช่น แยกรหัสพนักงานออกจากชื่อ และปรับประเภทข้อมูล (Data Type) ของแต่ละคอลัมน์ให้ถูกต้อง โดยเฉพาะคอลัมน์ตัวเลขอย่างเงินเดือนหรือค่าล่วงเวลาที่บางทีถูกเก็บเป็นข้อความ ทำให้บวกเลขไม่ได้ถ้าไม่แก้ตรงนี้ก่อน
จุดที่คนทำ Payroll มักพลาดถ้าไม่ใช้ Power Query
ถ้าทำความสะอาดไฟล์ Payroll ด้วยมือใน Excel ตรงๆ ทุกเดือน จะเสียเวลามากและเสี่ยงพลาดสูง เพราะต้องมานั่งลบแถว จัดคอลัมน์ ปรับ Format ใหม่ทุกครั้งที่มีไฟล์ใหม่เข้ามา จุดแข็งของ Power Query ที่ Lin เน้นย้ำคือทุกขั้นตอนที่ทำจะถูกบันทึกไว้เป็นสูตร (Applied Steps) ทำให้เดือนถัดไปแค่กด Refresh ไฟล์ใหม่ก็จะถูกทำความสะอาดด้วยขั้นตอนเดิมทันทีโดยไม่ต้องทำซ้ำตั้งแต่ต้น ประหยัดเวลาไปได้มากสำหรับงานที่ต้องทำซ้ำทุกเดือนแบบ Payroll
สรุป: คุ้มไหมที่จะลงทุนเวลาเรียน Power Query สำหรับงาน Payroll
สำหรับใครที่ต้องจัดการไฟล์เงินเดือนหรือไฟล์รายงานที่มีรูปแบบไม่นิ่งอยู่เป็นประจำ การลงทุนเวลาเรียนรู้ Power Query ถือว่าคุ้มมาก เพราะทำครั้งเดียวแล้วใช้ซ้ำได้ทุกเดือน ลดความเสี่ยงจากการพิมพ์หรือลบข้อมูลผิดด้วยมือ และทำให้ไฟล์พร้อมต่อยอดไปทำ Pivot Table หรือ Dashboard ใน Power BI ได้ทันที ถ้ายังไม่เคยลองมาก่อน คลิปนี้เป็นจุดเริ่มต้นที่ดีเพราะสอนแบบละเอียดทุกขั้นตอนจากเคสจริง
🇬🇧 Power Query step by step: cleaning up a real Payroll file
This article is summarized from the Lin Davoy channel. This video walks through a real-world case that HR and payroll teams run into constantly: a payroll file exported straight from the payroll system that is not ready to use as-is. These exports typically come with multi-row headers stacked on top of each other, subtotal rows scattered in the middle of the data, or columns that store numbers as text. Lin walks through cleaning up a file like this using Power Query, step by step in detail, so the result is actually usable for analysis or a dashboard.
Why payroll files almost always need Power Query first
Payroll exports from HR systems are usually designed to be read by humans, not by software, so the same problems tend to show up at nearly every company. The header row is not on the first line, blank rows separate departments, some columns use merged cells, or an employee ID and name are jammed into a single cell. Feeding a file like that straight into a Pivot Table or a chart usually produces distorted results. Power Query is the right tool for turning a file like this into a proper, machine-readable table before it gets used for anything else.
The main cleanup steps for a Payroll file
In the video, Lin walks through it step by step in detail: load the file into the Power Query Editor, then promote the correct row to become the header (Promote Headers), then remove unnecessary rows such as report title rows, blank rows, or subtotal rows sitting in the middle of the data. After that comes fixing columns where data got merged together, such as splitting an employee ID out from a name, and correcting the data type of each column, especially numeric columns like base salary or overtime pay that sometimes get stored as text, which silently breaks any sum or calculation until it is fixed.
What people usually get wrong without Power Query
Cleaning a payroll file by hand in Excel every single month is slow and error-prone, since you end up deleting rows, rearranging columns, and reformatting from scratch every time a new file lands. The real strength of Power Query that Lin emphasizes is that every step gets recorded as a formula, the Applied Steps list, so next month you just hit Refresh and the new file gets cleaned using the exact same steps automatically, with no need to redo any of the work from scratch. That is a significant time saver for a recurring task like payroll.
Verdict: is it worth learning Power Query for payroll work
For anyone who regularly handles payroll files or reports with an inconsistent layout, investing time in learning Power Query pays off quickly. You set it up once and reuse it every month, cut down the risk of manual copy-paste or deletion mistakes, and end up with a file that is immediately ready for a Pivot Table or a Power BI dashboard. If you have never tried it before, this video is a solid starting point since it walks through every step in detail using a real case.
ติดตามข่าวสาร Data & AI ได้ที่:
Facebook: https://www.facebook.com/davoytech
YouTube: https://www.youtube.com/@linlinmhee
📌 อย่าลืมกด Like, Share และ Subscribe เป็นกำลังใจให้ด้วยนะคะ!
💬 ใครเคยปวดหัวกับไฟล์ Payroll ที่ export มาแล้วหน้าตาไม่พร้อมใช้บ้างคะ มาคอมเมนต์เล่าปัญหาที่เจอบ่อยที่สุดให้ฟังหน่อย
#Davoy #DavoyTech #Linlinmhee #เรียนAI #คอร์สAI #DataAndAI #PowerQuery #PowerBI #Payroll #ExcelTips
