⚡0 XP🔥0

Power Query in Power BI and the Date Table

Lesson 2 of 6 ⏱ 4 min read ❓ 5-question quiz

Clean and shape data with Power Query inside Power BI - applied steps, data types with locale, merge and append, query folding basics, parameters, and creating a proper Date (calendar) table with DAX.

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.

Practice files

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.

Common Mistake

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#

  1. Remove columns you don't need - smaller, faster models.
  2. Set correct data types (whole number, decimal, date, text).
  3. Rename steps meaningfully (right-click → Rename) - "Fixed city names" is clearer than "Replaced Value2".
  4. Avoid hard-coded file paths: Manage Parameters → New Parameter (e.g. DataFolder) and use it in the Source step - easier to move the report.
  5. 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.
  6. 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:

  1. Table tools → Mark as date table → choose the Date column.
  2. Select Month → Column tools → Sort by column → Month No (otherwise months sort alphabetically: Apr, Aug, Dec...).
  3. Create a relationship Date[Date] → Sales[order_date] in Model view (next lesson).
Tip

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.

Quick Quiz

Q1.

Where do you open Power Query in Power BI Desktop?

Q2.

Why does a data model need a separate Date table?

Q3.

Which is the BEST place to fix data types and clean text?

Q4.

CALENDAR(DATE(2024,1,1), DATE(2025,12,31)) creates...

Q5.

Removing unused columns in Power Query helps because...