Column selection
Choose columns for a defined output
Column selection keeps required fields; renaming changes their labels; row filtering changes the subset of records. They are different transformations. For a local North sales report, keep line ID for audit, order ID for distinct order calculations, order date for time analysis, product key for future modeling, region for scope, and quantity and unit price for revenue. This revenue-only output deliberately excludes unit cost; it is not suitable for profit or margin analysis. Preserve the raw source and its data dictionary. Use Choose Columns or Remove Other Columns to define a whitelist of required fields; use Rename to make a label unambiguous. Keep the fields needed by downstream steps until after their last use.
Example 1: build a typed North report query
In a disposable Desktop project, import labs/fixtures/sales.csv using Text/CSV and choose Transform Data. Create the staging query SalesRaw from the CSV (first row headers); confirm exact field names. For the lab use the source immediately after header promotion, without automatic Changed Type; if necessary remove the automatic step and check dependencies. Create a new query named NorthSales and use the following complete expression in Advanced Editor. It depends on the separate SalesRaw query and is a static snippet, not a standalone file connector. Int64.Type is a whole-number type; Currency.Type is fixed decimal. The fixture contains integer-valued prices and ISO dates and uses en-US culture.
let Source = SalesRaw, Typed = Table.TransformColumnTypes(Source, { {"LineID", type text}, {"OrderID", type text}, {"OrderDate", type date}, {"ProductKey", type text}, {"Region", type text}, {"Quantity", Int64.Type}, {"UnitPriceUSD", Currency.Type}, {"UnitCostUSD", Currency.Type} }, "en-US"), North = Table.SelectRows(Typed, each [Region] = "North"), Selected = Table.SelectColumns(North, {"LineID", "OrderID", "OrderDate", "ProductKey", "Region", "Quantity", "UnitPriceUSD"}), Renamed = Table.RenameColumns(Selected, {{"Quantity", "Units"}}), Sorted = Table.Sort(Renamed, {{"LineID", Order.Ascending}})in SortedExpected result: three rows L01, L02 and L04; seven columns; Units sum 4; revenue calculated separately as Units × UnitPriceUSD sums to 104 USD. Two South rows with 96 USD are deliberately outside scope, not data-quality failures. The step sorts the query result for inspection; configure visual sort explicitly because the semantic model does not promise row display order. This query assumes a validated clean input; it is not a complete dirty-data cleaning pipeline.
Example 2: audit error removal before applying it
On a separate disposable query SalesDirtyRaw imported with headers from sales-dirty.csv, convert only OrderDate to date using en-US. One date, L07, is invalid. Create separate queries referencing that typed result: Table.SelectRowsWithErrors(TypedDirty, {"OrderDate"}) for audit and Table.RemoveRowsWithErrors(TypedDirty, {"OrderDate"}) for the date-valid subset, where TypedDirty names the typed query. These are expressions for the formula bar (prefix = there) or the body of a blank query. Expected counts are one rejected and eight date-valid rows. They do not detect the repeated L05, unknown product L06, or missing quantity L08. Missing quantity may be null rather than an error. Do not load the date-valid subset as a certified report. The prior chapter defines the additional checks required to obtain five accepted rows. Store rejected records with the original raw values and reason; the error cell itself is not the original text. Native M error conversion and row removal NOT RUN.
Common mistake: deleting evidence or required fields
Removing every error row across all columns without an approved policy can hide legitimate revenue. Preserve raw records, select relevant error columns and quarantine errors before excluding them from a report. The selected-column example raises an error by default when a required column is missing; investigate schema drift rather than quietly creating nulls. Renaming a field also changes its downstream name. If a later expression references Quantity after it becomes Units, update the expression or retain the old name deliberately. Do not apply the North filter to a full-company revenue report.
Practice: complete the local query audit
Use labs/power-query-editor/ to build the clean North result, predict the date-valid and date-error subsets of the dirty file, and reconcile counts and amounts. Explain whether cost-based margin can be computed from NorthSales alone. The worksheet works offline; a native lab requires an approved Desktop environment and should record the exact build and actual outputs separately.
Official reading
Table functions · Select columns · Rename columns · Filtering · Best practices. Source extracts reviewed; full signatures, native output and version support remain pending.