AES Class Clinic · Internal Reference
AES Class Operations Dashboard
Data Dictionary
คู่มืออธิบายแต่ละหน้า แต่ละกราฟ และแต่ละตารางของ Dashboard — แหล่งข้อมูล สูตรคำนวณ และข้อจำกัด
🌐 URL: aes-ops-dashboard.pages.dev
📅 อัปเดต: 27 มิถุนายน 2569
📝 Version: 3.0
ภาพรวม Architecture
Dashboard สร้างจาก build script Python → HTML เดี่ยว → deploy บน Cloudflare Pages
BigQuerynclinic2 / dynamics_bc
→
Superset MCPexecute_sql
→
build_full_dashboard.pyPython data + HTML template
→
index.htmlself-contained ~120KB
→
Cloudflare Pagesaes-ops-dashboard
ไฟล์หลัก
| Build script | C:\...\AES-Analytics\build_full_dashboard.py — embed Python data arrays เข้า HTML template |
| Output HTML | ytd_pl_dashboard_2026.html + index.html (เหมือนกัน) |
| Daily runner | run_daily_update.ps1 — Task Scheduler 06:27 ทุกวัน → Claude CLI → query → rebuild → deploy |
| Log | update_log.txt |
แหล่งข้อมูล (Data Sources)
BigQuery project: aesclass-portal
nclinic2 NClinic — ระบบ POS คลินิก (Revenue / Visit / Product)
dynamics_bc Dynamics 365 BC — บัญชี/สต็อก (COGS จริง, lag ~57 วัน)
PPTX Management Meeting Deck (seed data ประมาณการ)
Computed คำนวณใน Python/JS จากข้อมูลข้างต้น
ตาราง BigQuery ที่ใช้
| Table | Dataset | คำอธิบาย | Field หลัก |
get_sale_account |
nclinic2 |
บันทึกรายการขาย/บริการแต่ละรายการ (หลังหักส่วนลด) |
sale_date, organize (สาขา), sale_acc (ยอดขาย ฿), cn (รหัสคนไข้), item_name (ชื่อสินค้า/บริการ) |
get_visit |
nclinic2 |
บันทึก visit รายคนไข้ รายวัน |
visit_date, organize, hn (HN), come_count (1=ใหม่, >1=กลับมา), finished |
item_ledger_entries |
dynamics_bc |
รายการ stock ledger จาก Dynamics 365 BC (ตัดสต็อก = COGS จริง) |
posting_date, entry_type, cost_amount_actual, description (item name) |
⚠️ ข้อจำกัดสำคัญ
| BC Lag ~57 วัน | ข้อมูล item_ledger_entries ล่าช้า ~57 วัน — COGS เดือนปัจจุบัน = 0 (ยังไม่ interface) |
| entry_type COGS | ใช้เฉพาะ entry_type = 'Negative_x0020_Adjmt_x002E_' เท่านั้น — entry type Sale มีข้อมูลขยะ (ยอดสูงผิดปกติ 5 พันล้าน) |
| Product Grouping | ใช้ REGEXP บน item_name / description — ไม่ได้ JOIN master table → กลุ่ม "Other" อาจมี items ที่ควรจัดกลุ่มใหม่ |
| get_receipt ลบแล้ว | ตาราง nclinic2.get_receipt ถูกลบออกแล้ว — query ที่ JOIN ตารางนี้จะ error |
Tab 1 — รายวัน (Daily)
แสดงรายได้และ KPI ประจำวัน — อัปเดตทุกเช้า 06:27 น. | ข้อมูลถึง D-1 (เมื่อวาน)
KPI Flash Row (5 การ์ด)
| การ์ด | สูตร / Logic | แหล่งข้อมูล |
| Revenue D-1 (฿) | SUM(sale_acc) วันล่าสุดใน daily_rows | get_sale_account |
| Visits D-1 | COUNT(DISTINCT cn) วันล่าสุด | get_sale_account |
| Rev/Visit D-1 | Revenue D-1 ÷ Visits D-1 | Computed |
| 14-Day Total | SUM(revenue) 14 วันล่าสุด (ทุก branch ที่เลือก) | get_sale_account |
| 14-Day Avg/Day | 14-Day Total ÷ 14 | Computed |
ภาพที่ 1 — Revenue Trend Bar + Variance Strip Canvas: trendChart + trendVar
| องค์ประกอบ | คำอธิบาย | สูตร |
| แท่ง Revenue (สี teal) | Revenue รายวัน D-13 ถึง D-1 รวมทุก branch ที่เลือก | SUM(revenue) per date from daily_rows |
| D-1 highlight (สีเข้ม) | วันล่าสุดเน้นสี #123c38 | index === lastIndex → darker color |
| เส้นค่าเฉลี่ย (avg line) | ค่าเฉลี่ยของ window 7 หรือ 14 วัน (toggle ด้านบน) | SUM(revenue, window) / window_size |
| Variance Strip (สีเขียว/แดง) | แถบใต้กราฟ — ∆ รายวัน vs ค่าเฉลี่ย | (daily_rev - avg) / avg × 100 เป็น % |
| Label วันไทย | จ/อ/พ/พฤ/ศ/ส/อา ใต้แกน x + แท่งวันหยุด (ส/อา) สีอ่อน | JS Date → getDay() → map Thai |
Avg window toggle: ปุ่ม 7วัน/14วัน — เปลี่ยน avg line + variance strip พร้อมกัน
ตารางที่ 1 — Daily Flash Table (Integrated) Element: t1body
| คอลัมน์ | สูตร | แหล่งข้อมูล |
| สาขา | Branch name จาก BN map | Static |
| D-1 Revenue (฿) | Revenue เมื่อวานของสาขานั้น | get_sale_account |
| Ranking bar (inline) | Bar width = D-1 rev ÷ max D-1 rev ทุก branch × 100% | Computed |
| Δ vs Avg | Variance bar สีเขียว/แดง = (D-1 - avg) / avg | Computed |
| Sparkline 14 วัน | SVG polyline revenue 14 วัน + จุดแดงที่ D-1 | daily_rows |
| รวม 14 วัน | SUM(revenue, 14 days) ของสาขา | daily_rows |
⚠️ แถวไฮไลต์แดง + ⚠ เมื่อ D-1 ≤ −30% vs avg (alert threshold)
ภาพที่ 2 — Hero Products (Lifting machines) Canvas: heroChart
| Field | รายละเอียด |
| สินค้า Hero | Ulthera / Oligio / Thermage / Ultraformer / Morpheus |
| Filter | REGEXP บน item_name: r'ULTHERA|ULTRAFORMER|OLIGIO|THERMAGE|MORPHEUS' |
| Window | 7 วัน / 14 วัน / 30 วัน (toggle pills) |
| สูตร | SUM(sale_acc) per (branch, hero_brand, window) — เรียงตาม 30-day DESC |
| แหล่งข้อมูล | get_sale_account — stored in hero_rows array |
ภาพที่ 3 — New vs Returning Visits Canvas: nrChart
| Field | รายละเอียด |
| New Visit | come_count = 1 (visit ครั้งแรกในวันนั้น) |
| Returning Visit | come_count > 1 |
| Filter | finished = 1 (เสร็จแล้ว) เท่านั้น |
| แหล่งข้อมูล | get_visit — stored in nr_rows [date, org, tot, new, ret] |
| สูตร % ใหม่ | new_visits / total_visits × 100 |
Tab 2 — รายเดือน (Monthly)
เปรียบเทียบรายได้รายเดือน 2026 vs 2025 | เลือกดูรายเดือนผ่าน pills
Month Selector Pills + KPI เดือน
| องค์ประกอบ | Logic |
| Month pills | ม.ค. ถึงเดือนปัจจุบัน — click → filter charts/table เป็นเดือนนั้น |
| Revenue (เดือน) | SUM(sale_acc) ทุก branch ที่เลือก เดือนนั้น |
| YoY % | (rev_2026 - rev_2025) / rev_2025 × 100 |
| Visits (เดือน) | COUNT DISTINCT HN per month (from BR_MO) |
| Rev/Visit | Revenue ÷ Visits |
ภาพที่ 4 — Monthly Revenue Bar (2026 vs 2025) Canvas: monthRevChart
| Dataset | สูตร | แหล่งข้อมูล |
| 2026 (teal) | SUM(sale_acc) per (branch, month) 2026 | get_sale_account |
| 2025 (gray) | SUM(sale_acc) per (branch, month) 2025 | get_sale_account |
| เส้น YoY% | (rev26-rev25)/rev25×100 per month | Computed |
เดือน Jun MTD = ข้อมูลยังไม่ครบเดือน (ถึง D-1) — label มี * กำกับ
ตารางที่ 2 — Branch × Month Revenue Element: t2body
| คอลัมน์ | สูตร |
| Rev 2026 (M฿) | SUM(sale_acc) เดือนที่เลือก ปี 2026 ของสาขา |
| Rev 2025 | SUM(sale_acc) เดือนเดียวกัน ปี 2025 |
| YoY | chip สีเขียว/แดง = (26-25)/25×100 |
| Visits | COUNT DISTINCT HN เดือนนั้น |
| Rev/Visit | Rev ÷ Visits |
| สัดส่วน | Rev สาขา ÷ Rev รวม chain × 100% |
Tab 3 — YTD รายเดือน
ภาพรวม YTD ม.ค.–พ.ค. 2026 — Revenue + COGS รายเดือน + ตาราง P&L เดือน + YTD Branch
KPI Row — YTD Summary
| การ์ด | สูตร | แหล่งข้อมูล |
| Revenue YTD | SUM(rev26[m]) ทุกเดือน ม.ค.–ปัจจุบัน | get_sale_account |
| YoY Revenue | (sum26 - sum25) / sum25 | Computed |
| COGS YTD | SUM(cogs26[m]) ทุกเดือน (COGS จาก BC) | item_ledger_entries |
| Gross Profit YTD | Revenue YTD − COGS YTD | Computed |
| GP Margin % | GP ÷ Revenue × 100 | Computed |
ภาพที่ 5 — YTD Monthly Revenue 2026 vs 2025 Canvas: ytdRevChart
| Field | รายละเอียด |
| Data source | YTD_MO.rev26[month] / YTD_MO.rev25[month] |
| Aggregation | SUM(sale_acc) per (month, year) — branch filter applied via scale ratio |
| Scale logic | ถ้าเลือกบางสาขา: ยอดจาก BR_MO (สาขาที่เลือก) ÷ รวมทุกสาขา |
ภาพที่ 6 — Revenue + COGS + GP + YoY% Canvas: ytdCogsChart
| Dataset | สูตร | หมายเหตุ |
| Revenue (bar teal) | YTD_MO.rev26[m] | ม.ค.–มิ.ย. MTD |
| COGS (bar red) | YTD_MO.cogs26[m] | จาก item_ledger_entries Negative Adjmt. — มิ.ย. = 0 (BC lag) |
| GP (line gray dash) | Revenue − COGS per month | Computed |
| YoY% (line teal) | (rev26-rev25)/rev25×100 | secondary Y-axis (right) |
ตารางที่ 4 — Monthly P&L Summary Element: t4body
| คอลัมน์ | สูตร | แหล่งข้อมูล |
| Revenue 2026 | YTD_MO.rev26[m] × branch_scale | get_sale_account |
| Revenue 2025 | YTD_MO.rev25[m] × branch_scale | get_sale_account |
| YoY | (rev26-rev25)/rev25×100 | Computed |
| COGS 2026 | YTD_MO.cogs26[m] × scale | item_ledger_entries |
| GP | Rev26 − COGS26 | Computed |
| GP% | GP ÷ Rev26 × 100 | Computed |
| Visits | YTD_MO.vis26[m] = COUNT DISTINCT CN | get_sale_account |
| Rev/Visit | Rev26 ÷ Visits | Computed |
ตารางที่ 5 — YTD Branch Revenue Element: t5body
| คอลัมน์ | สูตร |
| Rev 2026 YTD | BR_YTD[branch].rev26 = SUM ม.ค.–ปัจจุบัน |
| Rev 2025 YTD | BR_YTD[branch].rev25 เดือนเดียวกัน |
| YoY | (rev26-rev25)/rev25×100 |
| Visits | BR_YTD[branch].vis26 = COUNT DISTINCT CN YTD |
| Rev/Visit | rev26 ÷ vis26 |
| สัดส่วน % | rev26_branch ÷ rev26_total × 100 |
Tab 4 — Product Mix (สัดส่วนสินค้า)
แบ่งรายได้เป็น 4 กลุ่มสินค้าหลัก — ม.ค.–พ.ค. 2026 | ข้อมูล: get_sale_account + D365 BC
Product Grouping Logic (REGEXP บน item_name)
| กลุ่ม | REGEXP Pattern | ตัวอย่าง item |
| Lifting | ULTHERA|ULTRAFORMER|OLIGIO|THERMAGE|MORPHEUS|HIFU|EXILIS|VENUS|SCULPSURE | Ulthera, Oligio, Thermage FLX |
| Injection | BOTOX|DYSPORT|XEOMIN|FILLER|JUVEDERM|RESTYLANE|SCULPTRA|RADIESSE|PROFHILO|NEURONOX|NABOTA|REVOLAX|PLINEST|MOUNJARO | Botox, Filler, Mounjaro |
| Pico & Laser | PICO|PICOCARE|LASER|FRAXEL|CO2|IPL|PICOWAY|ENLIGHTEN|TONING|PIGMENT | PicoSure, CO2 Laser |
| Other | ไม่ตรงกับ pattern ข้างต้น | Skincare, Package, Consultation |
⚠️ Pattern matching ไม่สมบูรณ์ 100% — items บางรายการอาจจัดกลุ่มไม่ตรง เนื่องจาก item_name ไม่ได้ standardized
ภาพที่ 7 — Product Mix รายเดือน Stacked Bar Canvas: prodStackChart
| Field | รายละเอียด |
| สูตร | SUM(sale_acc) per (branch, product_group, month) |
| Data structure | PROD_BR[branch][month][group] = revenue (฿) |
| Branch filter | sum เฉพาะ branch ที่เลือก |
| แหล่งข้อมูล | get_sale_account — prod_rows_batch1/2/... |
ภาพที่ 8 — Product Mix YTD Doughnut Canvas: prodPieChart
| สูตร | SUM(revenue, ม.ค.–พ.ค.) per group |
| Label tooltip | Group name + M฿ + สัดส่วน % |
ภาพที่ 9/10 — Lifting/Injection YoY เปรียบเทียบ liftYoyChart / injYoyChart
| 2026 (teal) | byMonth[m]['Lifting'] สาขาที่เลือก |
| 2025 (light teal) | byMonth25[m]['Lifting'] — scale ตามสัดส่วน branch |
| 2025 data | PROD_MO['2025-mm'][group] = ยอดรวม chain ปี 2025 |
ตารางที่ 6 — Product Mix YTD แยกสาขา Element: t6body
| คอลัมน์ | สูตร |
| Lifting / Injection / Pico / Other (฿) | SUM revenue per group ม.ค.–พ.ค. ของสาขา |
| % (สัดส่วน) | group_rev ÷ branch_total × 100 |
| รวม | SUM ทุก group ของสาขา |
Direct Material Margin ราย Product Group Canvas: prodMarginChart + t-margin-body
| Field | รายละเอียด |
| Revenue (chain) | SUM ทุก branch จาก PROD_BR — ไม่ผ่าน branch filter |
| Direct COGS (chain) | COGS_PROD['2026-mm'][group] × 1e6 — จาก item_ledger_entries Negative Adjmt. |
| Direct Margin | Revenue − COGS per group |
| Margin % | Margin ÷ Revenue × 100 |
| แหล่งข้อมูล COGS | item_ledger_entries — REGEXP บน description field |
⚠️ Direct Material Margin ≠ Gross Profit — ไม่รวม Doctor Fee / Med Staff / Rental / Overhead
มิ.ย. COGS = 0 / N/A เนื่องจาก BC lag ~57 วัน
ตารางที่ 7 — Direct Material Margin ราย Sub-Product Element: t-sub-body ประมาณการ ~85%
แสดง Revenue / COGS / Margin แยกย่อยระดับ sub-product ภายในแต่ละกลุ่มใหญ่ (Jan–May 2026 เท่ากัน)
| Field | รายละเอียด |
| Data blob | SUB_PROD_ROWS — [sub_product, major_group, rev_M, cogs_M] |
| Revenue | nclinic2.get_sale_account · REGEXP บน item_name · Jan–May 2026 |
| COGS | dynamics_bc.item_ledger_entries · REGEXP บน description · Jan–May 2026 |
| Margin % | (Revenue − COGS) ÷ Revenue × 100 · color badge: ≥80% teal / 60–79% เขียว / 40–59% orange / <40% red |
| Revenue % | Revenue sub-product ÷ Revenue รวมทุกกลุ่ม × 100 |
| Branch filter | ❌ ไม่ filter — Revenue ใช้ chain-level (COGS ไม่มี branch dimension) |
| Sub-product | Major Group | Rev 5M (M฿) | COGS 5M (M฿) | Margin% | ความแม่นยำ |
| Ulthera | Lifting | 36.72 | 16.32 | 55.6% | 🟢 สูง |
| Oligio | Lifting | 22.52 | 3.20 | 85.8% | 🟢 สูง |
| Thermage | Lifting | 11.53 | 4.13 | 64.2% | 🟢 สูง |
| Ultraformer | Lifting | 9.31 | 2.56 | 72.5% | 🟢 สูง |
| Morpheus | Lifting | 2.12 | 0.38 | 81.9% | 🟢 สูง |
| Neurotoxin | Injection | 17.01 | 7.20 | 57.7% | 🟡 ปานกลาง |
| Filler | Injection | 14.43 | 5.94 | 58.8% | 🟡 ปานกลาง |
| Biostimulator | Injection | 11.63 | 6.21 | 46.6% | 🟡 ปานกลาง |
| Pico Laser | Pico & Laser | 10.37 | 0.60 | 94.3% | 🟢 สูง |
| CO2/Fractional | Pico & Laser | 3.94 | 0.00 | ~100% | 🔴 COGS=0 (อาจ uncategorized) |
| Other (Laser) | Pico & Laser | 3.47 | 0.00 | ~100% | 🔴 COGS=0 |
| Other | Other | 36.74 | 9.33 | 74.6% | 🟠 Bucket ใหญ่ ไม่ classified |
⚠️ ข้อจำกัดความแม่นยำ:
• Revenue regex ใช้ item_name (NClinic) ≠ COGS regex ใช้ description (BC) — อาจ misclassify บางรายการ
• CO2/Fractional & HIFU COGS = 0 — consumable อาจบันทึกภายใต้ชื่ออื่นใน BC
• Other bucket (36.7M) ขนาดใหญ่ — อาจมีผลิตภัณฑ์ที่ควรจัดกลุ่มได้หลุดเข้ามา
• ควรใช้เป็น "ประมาณการ" เท่านั้น ไม่ใช่ตัวเลข certified financial
Tab 5 — งบกำไรขาดทุน (Exec P&L)
P&L ระดับเครือ | 2024/2025 = ทั้งปี · 2026 YTD 5M · Forecast 12M | ข้อมูลไม่แยกสาขา
แหล่งข้อมูล P&L
| รายการ | แหล่งข้อมูล | หมายเหตุ |
| รายได้ (Revenue) 2026 YTD | get_sale_account actual | 179.96M ม.ค.–พ.ค. 2026 |
| ต้นทุนสินค้า (Inventory) 2026 YTD | item_ledger_entries actual | 55.86M Negative Adjmt. ม.ค.–พ.ค. 2026 |
| ต้นทุนแพทย์ / Med Staff / Overhead / Rental 2026 | PPTX slide 24 ประมาณการ | scaled จาก % 4M PPTX × revenue 5M จริง |
| S&M / Admin / D&A / Finance cost 2026 | PPTX slide 24 ประมาณการ | scaled ×(179.96/148.00) |
| ปี 2024 / 2025 (ทั้งปี) | PPTX slide 24 actual | board-approved figures |
| Forecast 2026F | PPTX slide 25 Case 1 | 3 scenarios |
KPI Cards (4 การ์ด)
| Revenue YTD | FIN.pnl[0].v[2] = 179.96M |
| GP + GP% | FIN.pnl[7].v[2] = 53.96M · FIN.pnl_pct.gp[2] = 30.0% |
| EBITDA + % | FIN.pnl[12].v[2] = 6.00M · FIN.pnl_pct.ebitda[2] = 3.3% |
| Net Profit/(Loss) | FIN.pnl[17].v[2] = −8.44M |
ภาพ P&L Bridge (Waterfall) Canvas: pnlWaterfall
| Step | สูตร |
| รายได้ | FIN.pnl[0].v[2] = 179.96M |
| − ต้นทุนบริการ | rev − total_cost = 179.96 − 126.00 |
| กำไรขั้นต้น | = 53.96M |
| − S&M | gp − sm |
| − Admin | |
| + อื่นๆ | asset gain + other income |
| EBITDA | = 6.00M |
ตาราง P&L เปรียบเทียบ 4 คอลัมน์ Element: pnl-body
แสดง FIN.pnl array ทุก row — คอลัมน์ highlight = i26=2 (YTD 2026 5M)
แถว % (cost%/GP%/EBITDA%) = FIN.pnl_pct object
Tab 6 — ต้นทุน & Margin (Cost)
เปรียบเทียบต้นทุนขายและบริการ YTD ม.ค.–พ.ค. ทุกปี | 2024/2025 = scaled ×5/4 จาก PPTX
แหล่งข้อมูลและ Period
| คอลัมน์ | Period | แหล่งข้อมูล | หมายเหตุ |
| YTD 2024 (5M) | ม.ค.–พ.ค. 2567 | PPTX slide 16 ×5/4 | ประมาณการ (scaled) |
| YTD 2025 (5M) | ม.ค.–พ.ค. 2568 | PPTX slide 16 ×5/4 | ประมาณการ (scaled) |
| YTD 2026 (5M) | ม.ค.–พ.ค. 2569 | Inventory: BC actual / อื่น: PPTX ประมาณการ | Inventory = ข้อมูลจริง |
ตารางต้นทุน — รายหมวด + % Element: cost-body
| บรรทัด | ค่า 2026 5M | แหล่งข้อมูล |
| ต้นทุนสินค้า (Inventory) | 55.86M | item_ledger_entries Negative Adjmt. actual |
| ต้นทุนแพทย์ (Doctor Fee) | 36.13M | PPTX ประมาณการ |
| ต้นทุนบุคลากรการแพทย์ | 10.37M | PPTX ประมาณการ |
| ค่าใช้จ่ายโสหุ้ยอื่น | 0.13M | PPTX slide 16 |
| ค่าเช่า (Rental) | 21.86M | PPTX ประมาณการ |
| รวมต้นทุนบริการ | 126.00M | Computed sum |
| % ต่อรายได้ | 70.0% | 126.00 ÷ 179.96 × 100 |
KPI Cards — Computed YoY
YoY % ทุกการ์ดคำนวณ อัตโนมัติ จากข้อมูลจริงใน FIN.cost_total / FIN.cost:
| Total cost YoY | (tot[2]/tot[1]-1)×100 = (126.00/116.75-1)×100 = +7.9% |
| Inventory YoY | (C[0].v[2]/C[0].v[1]-1)×100 = (55.86/48.34-1)×100 = +15.6% |
| Doctor YoY | (C[1].v[2]/C[1].v[1]-1)×100 = (36.13/32.86-1)×100 = +9.9% |
Tab 7 — ค่าใช้จ่าย S&M (OpEx)
Selling & Marketing แยกประเภท YTD ม.ค.–พ.ค. | 2024/2025 = scaled ×5/4
แหล่งข้อมูล S&M
ข้อมูลทั้งหมดจาก PPTX slide 20 — ยังไม่มีการ reconcile กับ GL จริง
2024/2025 scaled ×5/4 จาก Jan-Apr | 2026 scaled ×(179.96/148.00) จาก 4M PPTX
ตาราง S&M แยกประเภท Element: sm-body
| บรรทัด | ค่า 2026 5M |
| Commission พนักงาน | 15.48M |
| Digital Marketing | 6.01M |
| Credit Card Fee | 5.56M |
| อื่นๆ (Advertising/Event/Agent) | 3.03M |
| S&M รวม | 30.08M (16.7% ของ revenue) |
ภาพ % S&M ต่อรายได้ Canvas: opexPctChart
| สูตร | sm_total[i] / rev_ytd[i] × 100 |
| 2024 | 18.31 ÷ 145.46 = 12.6% |
| 2025 | 19.49 ÷ 156.69 = 12.4% |
| 2026 | 30.08 ÷ 179.96 = 16.7% |
Tab 8 — ประมาณการ (Forecast)
3 Scenarios ทั้งปี 2026 | ข้อมูลจาก PPTX slide 25 — board-approved
3 Scenarios
| Scenario | สมมติฐาน | Revenue | EBITDA | Net |
| Case 1 | โครงสร้างต้นทุนเท่า YTD 2026 | 438.29M | 5.82M | −30.39M |
| Case 2 | ลดงบการตลาด 30M | 408.29M | −0.12M | −36.33M |
| Case 3 | ต้นทุนเท่า YTD + เพิ่ม treatment revenue | 521.79M | 36.26M | +0.05M |
แหล่งข้อมูล: PPTX slide 25 — ค่าเหล่านี้ไม่ได้อัปเดตอัตโนมัติ
Branch Filter Logic
Pills ด้านบน — เลือก/ยกเลิก branch ที่ต้องการ
การทำงานของ Branch Filter
| Tab | Filter ทำงานไหม? | Logic |
| Daily, Monthly, YTD, Product Mix | ✅ ทำงาน | filter sel set → aggregate เฉพาะ branch ที่เลือก |
| Exec P&L, Cost, OpEx, Forecast | ❌ ไม่ทำงาน (hidden) | ข้อมูลเป็น chain-level ไม่มี branch dimension |
| Direct Material Margin | ❌ ไม่ filter | COGS จาก BC ไม่มี branch dimension — Revenue ใช้ chain-level เสมอ |
Auto-Update Pipeline
ขั้นตอนอัปเดตอัตโนมัติ (run_daily_update.ps1)
| Step | Query | อัปเดต array ใน build script |
| 1 | Daily Revenue 14 วัน (get_sale_account) | daily_rows |
| 2 | Product Mix by Branch × Month YTD 2026 (get_sale_account) | prod_rows_batch* |
| 3 | YTD Branch Revenue 2026 vs 2025 (get_sale_account) | branch_ytd_rows |
| 4 | Hero Products 7/14/30 วัน (get_sale_account) | hero_rows |
| 5 | COGS by Product Group รายเดือน (item_ledger_entries Negative Adjmt.) | cogs_prod_rows + fin_data P&L cascade |
| 6 | — (no query) | python build_full_dashboard.py → rebuild HTML → wrangler deploy |
ข้อมูลที่ไม่อัปเดต: New/Returning (nr_rows), fin_data Doctor/MedStaff/Rental/S&M/Admin, Forecast scenarios
ข้อจำกัดและความแม่นยำ
สรุประดับความน่าเชื่อถือ
| ข้อมูล | ระดับ | หมายเหตุ |
| Revenue (รายได้) | 🟢 High — actual | Reconcile กับ PPTX ±1.9%, realtime |
| Inventory COGS (ต้นทุนสินค้า) | 🟡 Medium — actual แต่ lag | D365 BC Negative Adjmt., lag ~57 วัน, reconcile ±2.9% |
| Doctor / MedStaff / Rental | 🟠 Estimate | Scale จาก % PPTX × revenue จริง |
| S&M / Admin / D&A | 🟠 Estimate | Scale จาก % PPTX × revenue จริง |
| 2024/2025 cost (YTD 5M) | 🔴 Rough estimate | PPTX 4M ×5/4 linear scaling — ไม่คำนึงถึง seasonality |
| Forecast scenarios | 🔵 Projection | จาก board deck — ไม่อัปเดตอัตโนมัติ |
พิมพ์เป็น PDF: กด Ctrl+P → Save as PDF
ตั้งค่า: Margins = None, Scale = 90%, Headers & Footers = off