Weekly Sales and Inventory Reporting That Updates Itself
A Canadian healthcare-products company needed its weekly sales and inventory reports to stop being a manual chore. The local team is small. IT is run centrally by the parent group. The data comes from a logistics provider — daily and weekly report files attached to emails — and it all had to end up in two places: a supply-chain workbook and a finance workbook.
The Problem
Every week someone copied and pasted the logistics files into a supply-chain workbook, then copied the same data again into a separate finance workbook. “I'm doubling the job.” Pivots and maps were refreshed by hand. Received quantities were typed in manually, which caused false shortages when the numbers didn't match what actually arrived. The inherited forecast was hard to follow. An earlier attempt to automate the pivots had made the file painfully slow.
The goal was straightforward: open the file and see up-to-date data, built to last.
What We Built
The solution has three links in a chain: capture, import, report.
1. Capture — Power Automate to SharePoint
A Power Automate flow watches a shared mailbox. When a new email arrives with attachments, the flow loops through them, keeps only .xls and .xlsx files, and saves them to an incoming folder on SharePoint. That's all this link does — get the files off the email and into a known location.
2. Import — scheduled PowerShell, no Excel needed
An hourly Windows scheduled task (and once at sign-in) runs a PowerShell script on a normal user's PC. No admin rights, no server. The script reads the incoming files directly in their file format — it doesn't open Excel at all. It appends new data to a yearly data file, skips anything already loaded, and sets restated reports aside for someone to approve before they go in.
This link has the most safeguards because it runs unattended:
- ✓ Rolling safety copy before every write.
- ✓ Refuses to write if the target file is already open.
- ✓ Run lock so two instances can't overlap.
- ✓ Import log for every run.
- ✓ Main/backup PC failover using heartbeat files. If the main PC hasn't run recently, the backup takes over. We ran eleven failover tests; all eleven passed.
When the import finishes, it writes a status file to SharePoint. A second Power Automate flow picks that up and posts an adaptive card to Teams so the team knows the data is fresh.
3. Report — one-click Excel workbook
One Excel workbook, powered by Power Query, pulls from the yearly data file. There's a single file-path setting to configure — point it at the data and everything else follows. The workbook contains:
- ✓ A dashboard.
- ✓ Sales by customer and region.
- ✓ Inventory and shelf life.
- ✓ A 12-month forecast with a reorder signal.
- ✓ A weekly summary.
- ✓ Year-end rollover built in.
Refresh is one button.
The Ownership Model
The client's IT group proposed an ownership model that worked well and that we'd use again.
A business user owns the Power Automate flows. The capture flow's connections are signed in as an existing service account that IT already manages. An IT admin is added as co-owner for backup.
Why this works:
- ✓ Flows run on the owner's licence, so the service account only needs a basic licence — no premium.
- ✓ Files land on SharePoint as the service account, so staff changes don't break file ownership.
- ✓ IT reuses an account and document library it already manages, with folder-level edit rights.
- ✓ If the owner leaves, the co-owner keeps the flow alive and can change the primary owner.
- ✓ A co-owner can't re-sign another owner's connection, but they can swap in a connection they sign themselves — so IT attaches the service-account connection without sharing the password.
- ✓ The service account needs Full Access to the shared mailbox. No Azure resources are used.
We proved the whole model first in the Jerts tenancy across seven tests before deploying to the client.
What Went Wrong (and What We Learned)
- ✓ A service-account password reset silently stopped the capture trigger. No failed run was logged — the flow just stopped firing. One re-sign of the connection fixed it, and the missed file was picked up on the next run.
- ✓ The flow designer silently fell back to the owner's own connection when the service-account connection broke. You have to check “Connected to…” on every step before saving, every time.
- ✓ The Teams notification card failed because the service account wasn't a member of the team. The final design posts the Teams card via the owner's Teams connection instead.
- ✓ Endpoint security — an attack-surface-reduction rule — blocked an Excel import button we'd built initially. We moved the import to a scheduled task instead, and the library files were allow-listed by hash.
- ✓ Driving Excel against a synced SharePoint file failed. That's unsupported unattended Office automation. So we rebuilt the import engine to work on the file format directly, without Excel.
Results
The system went live late October 2026. The first run imported the full backlog in one pass. It's been running hourly since. History back to January was reconciled against the client's own workbook — matched to the cent and on units. Double entry is gone. Refresh is one button. During testing, the old engine and the new engine produced identical data.
Technical Sidebar: Power Automate / Microsoft 365 Configuration
| Component | Detail |
|---|---|
| Capture flow trigger | “When a new email arrives in a shared mailbox (V2)” |
| Capture flow action | Loop attachments → keep .xls/.xlsx only → SharePoint “Create file” into incoming folder |
| Notification flow trigger | “When a file is created (properties only)” (watches for status file) |
| Notification flow action | Post adaptive card to Teams channel |
| Capture connection identity | Existing service account (Full Access to shared mailbox) |
| Notification Teams connection | Flow owner's Teams connection (service account not a team member) |
| Flow ownership | Business user = owner; IT admin = co-owner |
| Service account licence | Basic (non-premium) — flow runs on owner's licence |
| Import engine | PowerShell script; reads/writes Excel file format directly (no Excel process) |
| Import schedule | Hourly via Windows Task Scheduler + at sign-in; normal user rights |
| Import safeguards | Rolling safety copy, open-file check, run lock, import log |
| Failover | Main/backup PC via heartbeat files; 11 of 11 failover tests passed |
| Data store | Yearly data file on network/SharePoint; Power Query reads via single file-path setting |
| Azure resources | None |
| Pre-deployment testing | Ownership model proved in Jerts tenancy (7 tests) |
Configuration Lessons
- 1. Agree with IT before you design where the automation will run and as which account. Don't build first and ask permission later.
- 2. Service account + co-owner = continuity without sharing passwords. IT can step in without knowing the service account's credentials.
- 3. Flows run on the owner's licence. The service account doesn't need a premium licence if it's only providing connections.
- 4. Plan for password changes. When a service-account password is reset, re-sign every connection that uses it the same day. The flow won't warn you — it just stops.
- 5. Check “Connected to…” before saving. The designer silently falls back to the owner's own connection when a service connection breaks. Verify every step.
- 6. Service-account Teams posts need team membership. If the account isn't a member of the team, the card will fail. Use the owner's Teams connection instead, or add the account to the team.
- 7. Don't automate Excel against synced SharePoint files. Unattended Office automation against synced files is unsupported and will fail. Work on the file format directly.
- 8. Find out about endpoint security early. Attack-surface-reduction rules, antivirus, and DLP policies can silently block scripts and macros. Ask IT what's in place before you build.
Technology
Have a similar challenge?
If your weekly reports still start with copying and pasting files out of email, we can probably make them update themselves. Let's talk.
Get in Touch