🇹🇭 พา Claude Code มาช่วยทำ Power BI — ไม่ต้องปวดหัวกับ DAX อีกต่อไป
หลายคนคงเคยได้ยินความล้ำของน้อง Claude Code กันมาแล้วเนาะ ว่าช่วยเขียนโค้ดได้หลายภาษามาก ทั้งสร้างแอปพลิเคชัน เขียน React เขียน Python แต่สำหรับสายที่ใช้ Power BI อย่างเราล่ะ จะเอาน้องมาช่วยยังไง คลิปนี้มีคำตอบค่ะ และคีย์เวิร์ดสำคัญคือไฟล์นามสกุลใหม่ที่ชื่อ PBIP (สรุปจากคลิปของช่อง Lin Davoy)
รู้จัก PBIP — เปลี่ยน Power BI ให้กลายเป็นโค้ด
เมื่อก่อน Power BI มีนามสกุลไฟล์เดียวคือ .pbix ที่โยนทุกอย่างลงไปในไฟล์ก้อนเดียว เปิดได้เฉพาะบนเครื่องเราเท่านั้น แต่ Power BI รุ่นใหม่ๆ สามารถกด Save As แล้วเลือกเป็น .pbip (Power BI Project File) ได้ค่ะ แนะนำให้สร้างโฟลเดอร์แยกไว้ให้มัน 1 อัน เพราะพอเซฟแล้วมันจะแตกทุกอย่างออกมาเป็นไฟล์หลายไฟล์ในโฟลเดอร์นั้น ทั้งส่วน Semantic Model ส่วน Report และตัวไฟล์ .pbip เอง
หัวใจอยู่ตรงนี้ค่ะ ในโฟลเดอร์ Semantic Model จะมีไฟล์ Definition ของแต่ละ Table เขียนด้วยภาษาของ Power BI เองที่เรียกว่า TMDL (Tabular Model Definition Language) เท่ากับว่าทุกอย่างใน Power BI ของเราถูกแปลงกลับมาเป็นโค้ดที่เป็นตัวอักษรล้วนๆ ลองดับเบิ้ลคลิกไฟล์ Table ขึ้นมาดูได้เลย เป็นภาษาที่คนอ่านรู้เรื่อง แยกเป็นชิ้นส่วน แก้ทีละส่วนได้ค่ะ
| ประเด็น | .pbix (แบบเดิม) | .pbip (Project File) |
|---|---|---|
| รูปแบบไฟล์ | ก้อนเดียว ทุกอย่างรวมกัน | แตกเป็นหลายไฟล์ในโฟลเดอร์ |
| อ่านเนื้อในได้ไหม | ไม่ได้ ต้องเปิดผ่าน Power BI | ได้ เป็น Text/TMDL ที่คนและ AI อ่านออก |
| แก้ทีละส่วน | ทำไม่ได้ | แยกส่วน Model / Report แก้ได้อิสระ |
| ทำงานกับ Claude Code / Git | ไม่ Friendly | Friendly มาก ออกแบบมาเพื่อสิ่งนี้ |
วิธีเรียก Claude Code เข้ามาช่วย
ขั้นตอนง่ายมากค่ะ เปิด Terminal แล้ว cd เข้าไปที่โฟลเดอร์ที่เราเซฟ PBIP ไว้ (ถ้าชื่อโฟลเดอร์มีเว้นวรรคหรือขีด อย่าลืมใส่เครื่องหมายคำพูดครอบ Path ด้วยนะคะ) แล้วก็เรียกน้อง Claude ขึ้นมาในโฟลเดอร์นั้นได้เลย เท่านี้น้องก็อ่านไฟล์ Power BI ของเราได้ทั้งหมด และแก้ไขให้ได้ด้วย เพราะทุกอย่างเป็น Text File ที่ถูกออกแบบมาให้ Friendly กับ AI อยู่แล้วค่ะ ข้อดีอีกอย่างคือถ้าใครใช้ Claude Code อยู่แล้วจะรู้ว่าน้องทำ Version Control ด้วย Git ให้เองด้วย แก้พังก็ย้อนกลับได้
เคสจริง: ไฟล์บวม 30-40 MB จนรีเฟรชไม่ได้
เคสที่เจอมากับตัวคือโดนวางยาค่ะ มีไฟล์ Power BI ที่เขียน DAX ซับซ้อนมาก Redundant มากๆ จนไฟล์ใหญ่ผิดปกติ RAM 16 GB ยังกด Refresh ไม่ผ่าน ขึ้นว่า Memory ไม่พอ ทั้งที่ข้อมูลจริงไม่ได้เยอะเลย — Dashboard อื่นที่ใช้ข้อมูลชุดเดียวกัน Model Size ไม่ถึง 10 MB แต่ตัวนี้ล่อไป 30-40 MB เราก็เซฟเป็น PBIP แล้วปรึกษาน้องตรงๆ เลยว่าไฟล์นี้ทำไมใหญ่จัง น้องเข้าไปอ่าน TMDL แล้วสรุปมาให้เลยค่ะว่าเจออะไรบ้าง มีทั้ง Auto Date/Time Table มี Calculated Table หนักๆ มีการทำ Partition ด้วยการ Select คอลัมน์ และมี Calculated Column จำนวนมาก พร้อมเสนอแผนแก้เป็นข้อๆ 1-2-3-4-5 พอเราไฟเขียว น้องก็ลงมือแก้ไฟล์ในโปรเจค PBIP ให้เลย
สรุป
สูตรคือ เซฟไฟล์ Power BI เป็นนามสกุล PBIP ในโฟลเดอร์ของมันเอง แล้วเรียก Claude Code ในโฟลเดอร์นั้น น้องจะอ่านและแก้ไข Model, DAX และ Report ของเราได้เหมือนแก้โค้ดทั่วไป ในมุมคนทำงานจริง นี่คือทางออกของคนที่เจอ DAX ที่คนอื่นเขียนทิ้งไว้ซับซ้อนๆ หรือไฟล์บวมจนรีเฟรชไม่ได้ ไม่ต้องนั่งแกะเองให้ปวดหัวอีกต่อไปค่ะ
🇬🇧 Claude Code + Power BI: No More DAX Headaches
You have probably heard how capable Claude Code is at writing software — apps, React, Python, you name it. But what about those of us who live in Power BI? This video shows the bridge, and the key is a file format called PBIP. Summarized from the Lin Davoy channel.
PBIP: turning Power BI into code
Power BI traditionally used a single .pbix file — everything dumped into one blob you can only open on your own machine. Newer versions let you Save As .pbip (Power BI Project File). Give it its own folder, because it explodes into many files: the semantic model, the report, and the .pbip file itself. The magic is inside the semantic model folder: table definitions written in TMDL (Tabular Model Definition Language) — Power BI’s own language. Your whole report becomes plain, human-readable text, split into parts you can edit independently.
| Aspect | .pbix (classic) | .pbip (project) |
|---|---|---|
| File shape | Single binary blob | Folder of separate files |
| Readable content | No — Power BI only | Yes — plain text / TMDL |
| Edit piece by piece | Not possible | Model and report editable separately |
| Claude Code / Git friendly | No | Very — built for it |
Bringing in Claude Code
The workflow is simple: open a terminal, cd into the folder where you saved the PBIP project (quote the path if the folder name has spaces), and launch Claude Code there. Because everything is now AI-friendly text, Claude can read your entire Power BI project and edit it directly. Bonus: Claude Code manages git version control on its own, so any change can be rolled back.
Real case: a 30-40 MB file that refused to refresh
A real example from the video: an inherited Power BI file boobytrapped with extremely complex, redundant DAX. It grew so bloated that 16 GB of RAM could not refresh it — out-of-memory errors on a dataset that was not even big. Other dashboards on the same data had model sizes under 10 MB; this one was 30-40 MB. Saved as PBIP, Claude read the TMDL and diagnosed everything: auto date/time tables, heavy calculated tables, partitions built by selecting columns, and piles of calculated columns. It proposed a step-by-step fix plan (1-2-3-4-5), and on approval went in and edited the project files itself.
Takeaway
The recipe: save your Power BI file as PBIP in its own folder, launch Claude Code there, and let it read and edit your model, DAX and report like any other codebase. If you have ever inherited someone else’s tangled DAX or fought a bloated file that will not refresh, this is the way out — no more decoding it by hand.
ติดตามข่าวสาร Data & AI ได้ที่:
Facebook: https://www.facebook.com/davoytech
YouTube: https://www.youtube.com/@linlinmhee
📌 อย่าลืมกด Like, Share และ Subscribe เป็นกำลังใจให้ด้วยนะคะ!
💬 ใครเคยเจอไฟล์ Power BI ที่ DAX พันกันยุ่งเหยิงจนไม่กล้าแตะบ้างคะ ลองเอาวิธีนี้ไปใช้แล้วมาเล่าให้ฟังกันได้เลยนะคะ
#Davoy #DavoyTech #Linlinmhee #เรียนAI #คอร์สAI #DataAndAI #PowerBI #ClaudeCode #DAX #PBIP
