You’re thinking in the right direction (email trigger + attachment) — now the key is how to map and consolidate the data correctly.
Here’s the best practical approach using Microsoft Power Automate + Microsoft Excel
Goal (Your scenario)
Each week:
You receive an Excel file (stock report)
You want to:
- Match Product Code
- Update Stock value
- Place it under the correct date column
Recommended Solution (Step-by-step)
Step 1: Standardize both files
Source (Weekly file)
Must have:
- Product Code
- Product Name
- Stock
Convert it into an Excel Table (important)
Target (Consolidated file)
Structure like:
Product Code | Product Name | 01-Jan | 08-Jan | 15-Jan ...
Also convert into Excel Table
Step 2: Build Power Automate Flow
When a new email arrives (V3)
Filter:
- Subject = your report subject
- Has attachment = Yes
Step 1: Get attachment
Use:
- Get Attachment
- Create file (temporary in SharePoint/OneDrive)
Step 2: Read Excel data
Action:
- List rows present in a table
Step 3: Loop and update consolidated file
Apply to each (row from weekly file)
Inside loop:
Use:
- List rows (from consolidated file) OR better:
- Get row using key (Product Code)
Identify current week column
Example:
- formatDateTime(utcNow(),'dd-MMM')
This becomes your column name (e.g., 22-Mar)
Use:
Map:
- Product Code → match
- Date column → Stock value
Key Challenge (Important)
Excel connector needs:
So:
Best practice
- Pre-create date columns OR
Use:
Option A (Recommended)
Keep table like:
- Product Code | Date | Stock
Then append rows instead of updating columns
Option B (Your current structure)
- Pre-create weekly columns
- OR use Office Script (advanced)
Thanks
Manish