Power Query Pipeline: CSV to Model to Report (5 Shots)

Power Query Pipeline: CSV to Model to Report (5 Shots)

This guide presents a 5 Shots workflow for automatically combining monthly CSV files into a single standardized table, loading it into the Data Model, and delivering PivotTable reports. Power Query is Excel’s Get & Transform technology, which can import and transform data from a variety of sources, including CSV, JSON, PDF, and SQL. :contentReference[oaicite:5]{index=5}

Summary

StageKey TaskReference
IngestImport multiple files with Data ▶ Get Data ▶ From Folder:contentReference[oaicite:6]{index=6}
ParseSpecify CSV delimiter, encoding, and format with Using Locale:contentReference[oaicite:7]{index=7}
TransformClean columns, change data types, merge, and handle error rows (Keep/Remove/Replace):contentReference[oaicite:8]{index=8}
LoadLoad to the Data Model and create PivotTables:contentReference[oaicite:9]{index=9}
OperateReview refresh intervals, dependency order, and web/online limitations:contentReference[oaicite:10]{index=10}

Shot 1 — Pipeline Overview and Requirements

  1. Sources: Monthly CSV files, ERP exports, and REST responses (with future expansion through From Web). Power Query supports many sources, including CSV, JSON, PDF, SQL, and SharePoint. :contentReference[oaicite:11]{index=11}
  2. Flow: Automatically combine files with the same schema using From Folder ▶ Combine. :contentReference[oaicite:12]{index=12}
  3. Refresh: In “Connection Properties ▶ Usage,” you can configure automatic refresh by the minute and background refresh. :contentReference[oaicite:13]{index=13}

Tip: Keep the same column structure in monthly files in the folder, such as 2025-07_orders.csv and 2025-08_orders.csv. Power Query’s Combine wizard is most reliable when files use the same schema. :contentReference[oaicite:14]{index=14}

Shot 2 — Data Ingestion (From Folder to CSV Parser)

  1. Data ▶ Get Data ▶ From File ▶ From Folder ▶ select the folder ▶ Combine & Transform. :contentReference[oaicite:15]{index=15}
  2. In the CSV parser, explicitly specify the Delimiter, File Origin (encoding), and Type Detection. You can select comma, semicolon, tab, or a custom delimiter. :contentReference[oaicite:16]{index=16}
  3. For date and number locale differences, use Change Type ▶ Using Locale for safe conversion. For example, yyyy-mm-dd versus dd/mm/yyyy. :contentReference[oaicite:17]{index=17}
  4. If you need detailed control over encoding, quotation marks, and other settings, use Csv.Document function parameters (UTF-8 by default). :contentReference[oaicite:18]{index=18}
// Example: Specify delimiter and encoding with Csv.Document
Csv.Document(File.Contents(Path),[Delimiter=",", Encoding=65001, QuoteStyle=QuoteStyle.Csv])

Shot 3 — Transform and Standardize

  1. Remove unnecessary columns and standardize names: Changing header names is a major cause of refresh errors, so standardize headers using fixed rules. :contentReference[oaicite:19]{index=19}
  2. Set data types: Explicitly set text, whole number, and date/time types to keep the data quality bar green.
  3. Merge mapping tables: For example, standardize carrier names by merging and then expanding.
  4. Handle errors: Build guardrails with Keep/Remove errors and Replace values. :contentReference[oaicite:20]{index=20}
// Example: Remove error rows, then replace errors with blank values
try Table.TransformColumns(#"Changed Type", {{"Qty", each Number.From(_), Int64.Type}})
otherwise Table.ReplaceErrorValues(#"Changed Type", {{"Qty", 0}})

Shot 4 — Load to the Model and Refresh

  1. Load to the Data Model: Select Finish ▶ Load To… ▶ Add this data to the Data Model (or Power Pivot ▶ Add to Data Model). Then create PivotTables based on the model. :contentReference[oaicite:21]{index=21}
  2. Refresh strategy: Automate refreshes using the “Refresh every n minutes” and “Enable background refresh” settings in Connection Properties. :contentReference[oaicite:22]{index=22}
  3. Order: Power Query automatically calculates refresh order based on dependencies, refreshing upstream queries before downstream queries. :contentReference[oaicite:23]{index=23}

Shot 5 — Report Delivery and Operations

  1. PivotTable reports: Create model-based PivotTables for order count, return rate, OTD, and more, then place them on weekly/monthly sheets.
  2. Parameters: Use Manage Parameters to parameterize changing values such as folder paths and years, making it easy to switch them between deployments. :contentReference[oaicite:24]{index=24}
  3. Web/online considerations: Power Query in Excel for the web has source limitations, so tables and ranges within the same workbook refresh most reliably. :contentReference[oaicite:25]{index=25}

Sample Data (Logistics/E-Commerce)

Folder structure: \ECordersmonthly contains 2025-07_orders.csv, 2025-08_orders.csv, and more.

CSV columns: Order_ID, Date (yyyy-mm-dd), SKU, Qty, Ship_Date, Carrier, Return_Reason

Mapping table (Excel worksheet Mapping): Carrier_Raw → Carrier_Std (for example, CJ/Korea Express → CJ Logistics)

One-Page Guide for Production Deployment

  • Folder rules: Keep file names and column schemas fixed; only add monthly files.
  • Parser: Specify the delimiter, encoding, and locale, then test 10 rows.
  • Standardization: Standardize headers, merge mappings, and define error-row rules (Keep/Remove/Replace).
  • Load: Load to the Data Model and save a PivotTable template.
  • Operations: Document the refresh schedule, dependencies, and web/online limitations.

Note: Power Query’s From Folder is optimized for combining files with the same schema. Specify the CSV delimiter, encoding, and locale to improve reliability. Load reports into the Data Model and deliver them through PivotTables. :contentReference[oaicite:26]{index=26}

1 thought on “Power Query Pipeline: CSV to Model to Report (5 Shots)”

  1. Pingback: How to Reconcile Two Excel Lists and Flag Missing or Mismatched Records

Leave a Reply

Your email address will not be published. Required fields are marked *