Import a CSV
From a text file to a table
A CSV is a plain text file containing records separated into fields. A Power BI import turns those fields into columns in a semantic model. For this lesson, use only the original clean labs/fixtures/sales.csv from the package, not sales-dirty.csv or the product table. Each row is one order line, not necessarily one order. The goal is five valid lines and a numeric revenue check, not merely a successful import dialog.
Example 1: load the clean file
On an approved Windows Desktop installation, open a blank report. From Get data choose Text/CSV and select the clean sales file using its local path. Choose UTF-8 (65001), comma delimiter and no automatic type detection if offered. Open Transform Data rather than loading unreviewed types. Ensure the first record is the header: if the columns already have their correct names, do not promote another row. Otherwise use the first row as headers once. Rename the query Sales. The expected columns are LineID, OrderID, OrderDate, ProductKey, Region, Quantity, UnitPriceUSD and UnitCostUSD.
Set LineID, OrderID, ProductKey and Region to Text; OrderDate to Date; Quantity to Whole Number; UnitPriceUSD and UnitCostUSD to Fixed Decimal Number. Use en-US when parsing date or numeric text; the source dates are ISO YYYY-MM-DD, not timestamps. Inspect all five rows in this tiny fixture and check for conversion errors. Menu wording can vary by build. Native steps are a walkthrough, not an observed run.
Example 2: derive line revenue
Revenue is quantity times selling price on each line. In Power Query Editor choose Add Column > Custom Column, name it RevenueUSD, and enter this M expression (a custom-column expression, not a complete query):
[Quantity] * [UnitPriceUSD]Square brackets refer to the fields of the current row; * multiplies the numbers. Set the resulting column to Fixed Decimal Number. This adds data to the query result, not to the original CSV. The expected rows are:
| LineID | Quantity | UnitPriceUSD | RevenueUSD |
|---|---|---|---|
| L01 | 2 | 12 | 24 |
| L02 | 1 | 30 | 30 |
| L03 | 3 | 12 | 36 |
| L04 | 1 | 50 | 50 |
| L05 | 2 | 30 | 60 |
Check five unique LineIDs, four distinct OrderIDs and revenue 200 USD. Close & Apply to load the prepared query. The calculation is an early M preview; full applied-step and M lessons follow later. No DAX or native M test was run.
Common mistakes: headers and types
If the first line disappears, check whether headers were promoted twice. If Quantity is treated as text, multiplication can fail or visual aggregation can default to counting. Convert deliberately, rather than removing rows with errors to make the preview look clean. Do not multiply the sum of Quantity by the sum of UnitPriceUSD: those sums combine unrelated line prices and quantities. The imported five rows are the baseline for later reconciliation.
Practice
Without Desktop, read the CSV as text and write the expected types for its eight source fields. Calculate revenue for L02 and L05, count the distinct orders, then compute the total of all line revenues. With Desktop, compare the loaded table against the same checks. If a check fails, stop and diagnose it before building a chart.