Same Power Query, new home#
Everything you learned in Excel's Power Query works identically in Power BI: Home → Transform data opens the Power Query Editor with the same ribbon, Applied Steps and M language.
- sales_raw.csv - messy export
- sales.csv - clean (for a city → region lookup)
- products.csv - product master with cost price
- targets.csv - 2025 region targets
Exercise: clean sales_raw.csv in Power BI#
| # | Step | In the Power Query Editor |
|---|---|---|
| 1 | Load | Get data → Text/CSV → sales_raw.csv → Transform Data (not Load) |
| 2 | Duplicates | select all columns (Ctrl+A) → Remove Rows → Remove Duplicates |
| 3 | City text | Transform → Format → Trim, then Capitalize Each Word; Replace Values Bangalore → Bengaluru |
| 4 | Segment | Capitalize Each Word |
| 5 | Sales | Replace Rs. and , with nothing → Data type: Fixed decimal number |
| 6 | Dates | column type icon → Using Locale → Date, English (India) |
| 7 | Region blanks | load sales.csv as a second query, keep city+region, remove duplicates → Merge into sales_raw on city (Left Outer) → expand region → Add Conditional Column: if region is null then lookup region else region |
| 8 | Remove helper columns, rename query Sales |
|
| 9 | Close & Apply |
Check
After Close & Apply, the Table view should show 300 rows (status bar), 19 cities, no blank regions, sales as a number, and order_date from 2024-01-01 to 2024-06-29.
Date locale trap: if you change order_date to Date with the default (often English-US) locale, 05/03/2024 becomes 3 May instead of 5 March, and 27/02/2024 becomes an error. Always use Change Type → Using Locale → English (India) for Indian day-first dates - and spot-check a few rows.
Power BI में भी Power Query बिल्कुल Excel जैसा ही है - वही steps, वही Applied Steps।
सबसे ज़रूरी सावधानी: तारीख़ का locale। Indian तारीख़ें (दिन/महीना/साल) को अगर US setting में पढ़ा गया, तो 05/03/2024 = 3 मई हो जाएगा। इसलिए हमेशा Change Type → Using Locale → English (India) चुनें।
Merge and Append (recap)#
- Merge Queries - add columns from another table (Sales + Products → cost_price). Prefer doing lookups via relationships in the model (next lesson) instead of merging, unless you need the value at row level in Power Query.
- Append Queries - stack 2024 and 2025 files; Get data → Folder for many monthly files.
Good practices for Power Query in Power BI#
- Remove columns you don't need - smaller, faster models.
- Set correct data types (whole number, decimal, date, text).
- Rename steps meaningfully (right-click → Rename) - "Fixed city names" is clearer than "Replaced Value2".
- Avoid hard-coded file paths: Manage Parameters → New Parameter (e.g.
DataFolder) and use it in the Source step - easier to move the report. - Query folding: with databases (SQL Server etc.), many steps are translated into SQL and run on the server - keep foldable steps (filter, remove columns) early.
- Disable load for helper queries: right-click → uncheck Enable load.
The Date table#
Time-based analysis (Year-to-date, same period last year, month-over-month) needs a calendar table: one row for every date, no gaps.
Modeling → New table:
Date =
ADDCOLUMNS (
CALENDAR ( DATE ( 2024, 1, 1 ), DATE ( 2025, 12, 31 ) ),
"Year", YEAR ( [Date] ),
"Month No", MONTH ( [Date] ),
"Month", FORMAT ( [Date], "MMM" ),
"Year-Month", FORMAT ( [Date], "YYYY-MM" ),
"Quarter", "Q" & QUARTER ( [Date] ),
"Weekday", FORMAT ( [Date], "ddd" ),
"Weekday No", WEEKDAY ( [Date], 2 )
)
Then:
- Table tools → Mark as date table → choose the
Datecolumn. - Select
Month→ Column tools → Sort by column → Month No (otherwise months sort alphabetically: Apr, Aug, Dec...). - Create a relationship
Date[Date]→Sales[order_date]in Model view (next lesson).
CALENDARAUTO() creates a calendar covering all dates in the model automatically. For financial years starting in April (common in India), add "FY", IF(MONTH([Date]) >= 4, YEAR([Date]) + 1, YEAR([Date])) and use TOTALYTD(..., "31/3") for FY-to-date.
Summary#
- Home → Transform data opens Power Query; the steps are the same as in Excel.
- Set date types with locale for Indian dates; remove unneeded columns; rename steps; use parameters.
- Create a Date table with CALENDAR + ADDCOLUMNS, mark it as a date table, sort Month by Month No.