Power Query M Language
Master Course
Power Query ke buttons ke parde ke peeche jo powerful functional language execute hoti hai, use scratch se seekhein! Learn to read, write, optimize, and automate complex ETL workflows for Power BI, Excel, and Microsoft Fabric.
35
Complete Parts
30
Days Roadmap
10
Real-World Projects
110
Practice Questions
52
Interview Q&As
30-Day Structured Study Plan
Track your daily progress. Har roz ek topic aur uska hands-on practice task complete karein (Saved automatically in your browser).
Understand what M (Mashup) is, Power Query UI vs M code, and the ecosystem across Excel, Power BI, and Fabric.
Task: Open Advanced Editor in Power BI/Excel and inspect auto-generated M script.Step bindings, comma rules, dependency evaluation graph, and output generation.
Task: Write a manual calculation query adding 18% GST to a base amount.Strict PascalCase standard, comments (//, /* */), quoted identifiers (#"Changed Type").
Task: Intentionally write text.upper vs Text.Upper to observe error behavior.number, text, logical, date, time, datetime, duration, null constructors (#date, #time, #duration).
Task: Calculate age in days between today and your birthday using #date and #duration.Arithmetic (+ - * /), Comparison (= <> < >), Logical (and or not), and Ampersand & combination.
Task: Combine First, Middle, and Last name handling null values safely.Strict lowercase if/then/else, mandatory else clause, nested conditions.
Task: Create an Indian GST slab classifier (0%, 5%, 12%, 18%, 28%) based on item category.1D sequences, range operator (1..100), 0-based positional indexing (List{0}), safe navigation List{10}?.
Task: Generate numbers 1..50 and extract the 1st, 25th, and last element.List.Sum, List.Average, List.Count, List.Min, List.Max, List.Distinct, List.Sort.
Task: Compute total, average, and distinct count on a raw sales list.List.Transform, List.Select, List.Combine, and List.Generate (M's loop construct).
Task: Generate sequence of last 12 month-end dates using List.Generate.Key-value pairs representing table rows. Record[Field] access, nested records, Record vs List vs Table.
Task: Create an employee record with an address sub-record and extract the city.Record.Field, Record.FieldNames, Record.FieldValues, Record.Combine, Record.TransformFields.
Task: Programmatically extract all column headers of a record using Record.FieldNames.2D relational grid as a list of records. Table constructors (#table, Table.FromRecords, Table.FromRows).
Task: Build a 3-row, 3-column table manually using typed #table constructor.Table.AddColumn, Table.RemoveColumns, Table.RenameColumns, Table.SelectColumns.
Task: Dynamically keep only columns containing sales metrics from a wide table.Table.SelectRows, Table.Sort, Table.Distinct, Table.FirstN, Table.Skip.
Task: Deduplicate customer inquiries table keeping only the latest interaction.Text.Trim, Text.Clean, Text.Upper, Text.Start, Text.End, Text.Middle.
Task: Extract Indian PAN number and State Code from a 15-character GSTIN string.Text.BeforeDelimiter, Text.AfterDelimiter, Text.BetweenDelimiters, Text.Split, Text.Combine.
Task: Split unformatted address string into Street, City, State, and Pincode.Number.Round, Number.RoundDown, Number.IntegerDivide, Number.Mod, Number.Abs.
Task: Calculate carton packaging units and remaining loose items using IntegerDivide and Mod.Date.Year, Date.Month, Date.Day, Date.MonthName, Date.QuarterOfYear, Date.DayOfWeek.
Task: Build a complete Fiscal Calendar (April to March) from a single Date column.Date.AddDays, Date.AddMonths, Date.EndOfMonth, #duration, Duration.Days.
Task: Calculate invoice payment due dates (Net 45) and payment overdue days.Number.From, Text.From, Date.From, "1000" vs 1000, culture codes ("en-IN" vs "en-US").
Task: Safely cast currency text ("1,500.00") into a pure decimal number.Syntactic sugar for (_) => _[Column], row context record, nested lambda shadowing traps.
Task: Rewrite three UI-generated each expressions as explicit lambda functions.Function syntax (param as type) as type => body, optional parameters, function invocation.
Task: Create a reusable fxCleanPhone function removing symbols and keeping 10 digits.try ... otherwise, full try record ([HasError], [Value], [Error]), Table.ReplaceErrorValues.
Task: Convert a corrupt column containing {"1000", "ABC", "2500"} safely without crashing.null vs "" vs 0, null propagation in arithmetic, Table.FillDown, Table.ReplaceValue.
Task: Clean a messy merged ERP report using Table.FillDown and Table.FillUp.Grouping keys, aggregation specifications (List.Sum, Table.RowCount), retaining nested rows (each _).
Task: Group sales by Region: calculate Total Sales, Order Count, and Avg Ticket.Table.NestedJoin, Table.ExpandTableColumn, 6 Join Kinds (LeftOuter, Inner, LeftAnti, etc.).
Task: Identify "Lost Customers" (no orders placed) using Left Anti Join.Table.Pivot, Table.UnpivotOtherColumns, wide-to-tall normalization for Power BI modeling.
Task: Unpivot a 12-month cross-tab budget table into a normalized 3-column table.Power Query parameters, dynamic file paths, dynamic date filtering (DateTime.LocalNow).
Task: Build a dynamic query that filters transactions from the last 90 days relative to today.Folder.Files, file extension filtering, binary extraction, combining multiple Excel files.
Task: Build an automated pipeline consolidating 12 monthly branch files from a folder.SQL pushdown, View Native Query indicators, operations that fold vs break, enterprise tuning.
Task: Perform an end-to-end code audit on a slow query: eliminate step churn and preserve folding.Part 1: What is Power Query M & Its Ecosystem?
Power Query ka underlying architecture, M ka matlab, aur Microsoft ecosystem.
Easy Hinglish Explanation
Power Query ke andar jab aap kisi button par click karte hain (jaise Remove Duplicates ya Filter Rows), tab background mein Microsoft ek advanced functional programming language generate karta hai — jiska naam hai M Language (Data Mashup Language).
Why is it called "M"?
M = Data Mashup. Mashup ka matlab hota hai alag-alag sources (Excel, SQL Database, Web APIs, SharePoint) se data nikalna, unhe jodna, clean karna aur ek clean final format banana.
Where M is Used?
Microsoft Excel, Power BI Desktop, Power BI Service Dataflows, Microsoft Fabric (Dataflows Gen2), aur SQL Server Analysis Services (SSAS).
Part 2: Your First M Query & Advanced Editor
Excel aur Power BI mein code editor open karna aur pehla program run karna.
How to Open the Advanced Editor
Power BI: Home → Transform Data → Advanced Editor.
Excel: Data → Get Data → Launch Power Query Editor → View/Home → Advanced Editor.
let
A = 10,
B = 20,
Total = A + B
in
Total // Output: 30
Line-by-Line Breakdown:
let: Power Query ko signal deta hai ki steps (variables) shuru ho rahe hain.A = 10,: Variable A ko 10 assign kiya. End mein comma,lagana zaroori hai.B = 20,: Variable B ko 20 assign kiya.Total = A + B: Sum calculate kiya. Note: Aakhri step ke baad comma nahi hota!in: Declaration khatam, ab output evaluate karo.Total: Jo variable yahan likhte hain, wahi output return hota hai.
Part 3: Basic Syntax & Strict Case Sensitivity
M language ke strictly case-sensitive rules, comments, aur identifiers.
M is 100% Case-Sensitive!
Excel formulas ki tarah M forgiving nahi hai:
✓ Text.Upper("hello") → Correct (Output: "HELLO")
✗ text.upper("hello") → Expression.Error: The name 'text.upper' wasn't recognized!
Comments in M
Single-line and Multi-line comments:
// Single line comment
/*
Multi-line
comment block
*/
Quoted Identifiers (#"...")
Agar step name mein space ya special characters hon, toh use #"..." mein wrap karna zaroori hai:
#"Changed Type", #"Filtered Rows"
Part 4: Values and Data Types
M ke sabhi primitive aur structural data types with literal constructors.
| Data Type | Literal Constructor | Example | Real-World Business Use |
|---|---|---|---|
null |
null |
null |
Missing remarks, blank optional mobile numbers. |
logical |
true / false |
true |
IsActive, GSTVerified, IsReturn flags. |
number |
125, 99.50 |
18.5 |
Prices, quantities, tax rates. |
text |
"..." |
"Mumbai" |
Customer Names, Address, Order IDs. |
date |
#date(Y, M, D) |
#date(2026, 9, 8) |
Invoice dates, joining dates. |
time |
#time(h, m, s) |
#time(10, 30, 0) |
Office punch in/out time. |
duration |
#duration(d, h, m, s) |
#duration(2, 4, 30, 0) |
Delivery SLA, machine downtime interval. |
list |
{ item1, item2 } |
{10, 20, 30} |
1D sequence, distinct categories list. |
record |
[ Key = Value ] |
[ID=101, Name="Rahul"] |
Single database row entity. |
table |
#table(cols, rows) |
#table({"A"}, {{1}}) |
2D relational grid (List of records). |
Part 5: Expressions & Lazy Evaluation Graph
M compiler kaise calculations ko graph ke roop mein evaluate karta hai.
Lazy Evaluation (Dependency Graph)
M language line-by-line execute nahi hoti. Engine sirf unhi steps ko calculate karta hai jo final output step (in ke baad wala step) ko compute karne ke liye zaroori hain. Unused steps system memory mein execute hi nahi hote!
let
A = 10,
B = 20,
C = A + B,
UnusedCalculation = Number.Power(999, 99) // Engine skips this completely!
in
C // Output: 30
Part 6: Operators Reference & Combination
Arithmetic, relational, logical, aur M ka universal combination operator (&).
The Universal `&` Operator
M mein `&` operator text, lists, aur records sabhi ko jodta hai:
- Text:
"Keerti " & "Computer"→"Keerti Computer" - Lists:
{1, 2} & {3, 4}→{1, 2, 3, 4} - Records:
[A=1] & [B=2]→[A=1, B=2]
Comparison & Logical
Equality: =, Inequality: <>
Logical: and, or, not (Strictly lowercase!).
Part 7: Deep Dive into `let ... in` Block
Pipeline step chaining, intermediate variables, and practical multi-step examples.
let
Revenue = 250000,
Cost = 175000,
GrossProfit = Revenue - Cost,
MarginPercentage = (GrossProfit / Revenue) * 100
in
MarginPercentage // Output: 30%
Part 8: Conditional Logic (`if ... then ... else`)
M conditional syntax, mandatory else clause, and nested conditions.
The Mandatory `else` Rule
Excel formulas ki tarah aap else part chhod nahi sakte. M language mein if <condition> then <trueResult> else <falseResult> pura likhna compulsory hai!
let
SalesAmount = 65000,
Tier =
if SalesAmount >= 100000 then "Platinum Tier"
else if SalesAmount >= 50000 then "Gold Tier"
else if SalesAmount >= 20000 then "Silver Tier"
else "Bronze Tier"
in
Tier // Output: "Gold Tier"
Part 9: Lists (`{}`) & 16 Core Functions
1-Dimensional sequences, 0-based indexing, range generation, and list transformations.
List Indexing (0-Based)
let
Cities = {"Mumbai", "Delhi", "Bengaluru"},
First = Cities{0}, // "Mumbai"
SafeLookup = Cities{10}? // Safely returns null!
in
First
Core List Functions
List.Sum({10, 20, 30})→60List.Average({10, 20, 30})→20List.Distinct({"A", "B", "A"})→{"A", "B"}List.Transform({1, 2}, each _ * 10)→{10, 20}List.Select({15, 80}, each _ >= 40)→{80}
Part 10: Records (`[]`) & Field Projections
Key-value pairs representing individual table rows, and nested records.
let
Employee = [
EmpID = 101,
FullName = "Rahul Sharma",
City = "Pune",
Salary = 65000
],
SelectedCity = Employee[City] // Output: "Pune"
in
SelectedCity
Part 11: Tables (`#table`) & 25 Essential Functions
The primary tabular grid of Power Query, row/column slicing, and transformation functions.
let
TypedSales = #table(
type table [OrderID = Int64.Type, Customer = text, Amount = number],
{
{1001, "Acme Corp", 45000},
{1002, "Global Tech", 28000}
}
)
in
TypedSales
| Function Name | Official Syntax Summary | Purpose |
|---|---|---|
Table.AddColumn |
(table, newCol, generator, type) |
Calculated column add karta hai row context mein. |
Table.SelectRows |
(table, condition) |
Filter predicate ke basis par rows retain karta hai. |
Table.RemoveColumns |
(table, columns as list) |
Unnecessary columns delete karta hai. |
Table.RenameColumns |
(table, renames as list) |
Headers ko rename karta hai. |
Table.TransformColumnTypes |
(table, typeList, optional culture) |
Data types explicitly set karta hai. |
Table.Group |
(table, keys, aggregations) |
Group by summary metrics calculate karta hai. |
Table.NestedJoin |
(t1, key1, t2, key2, newCol, joinKind) |
Relational merge karta hai (6 join kinds). |
Table.UnpivotOtherColumns |
(table, pivotCols, attrCol, valCol) |
Wide matrix ko normalized tall format banata hai. |
Part 12: Text Functions Library
String cleaning, slicing, delimiters parsing, and sanitation.
Delimiter Extractions
let
Email = "rahul.sharma@keerticomputer.com",
User = Text.BeforeDelimiter(Email, "@"), // "rahul.sharma"
Domain = Text.AfterDelimiter(Email, "@") // "keerticomputer.com"
in
Domain
Text Cleaning & Slicing
Text.Trim(" Mumbai ")→"Mumbai"Text.Clean("Text#(cr)#(lf)")→ Removes control chars.Text.Start("27ABCDE1234F1Z5", 2)→"27"(State Code).Text.Select("Phone: 98765-43210", {"0".."9"})→"9876543210".Text.PadStart("45", 6, "0")→"000045".
Part 13: Number & Math Functions Library
Financial rounding, division, modular math, and calculations.
let
TotalUnits = 145,
BoxSize = 12,
FullBoxes = Number.IntegerDivide(TotalUnits, BoxSize), // 12 Boxes
RemainingUnits = Number.Mod(TotalUnits, BoxSize) // 1 Loose Unit
in
[Boxes = FullBoxes, Loose = RemainingUnits]
Part 14: Date, Time & Duration Functions
Fiscal calendar engineering, payment aging, and duration intervals.
let
InvoiceDate = #date(2026, 9, 1),
CreditDays = 45,
DueDate = Date.AddDays(InvoiceDate, CreditDays), // #date(2026, 10, 16)
Today = DateTime.Date(DateTime.LocalNow()),
DaysOverdue = Duration.Days(Today - DueDate)
in
DaysOverdue
Part 15: Type System & Safe Casting
Avoiding Expression.Error on type mismatch and handling international culture formats.
"1000" vs 1000: The Type Trap
Text "1000" aur Number 1000 alag data types hain. Text par mathematical + run karne se report refresh crash ho jati hai. Hamesha Number.From(...) ya Table.TransformColumnTypes use karein!
Part 16: Custom Columns & Row Context
Row-by-row calculated logic and how the UI writes M code.
#"Added Custom" = Table.AddColumn(
Source,
"TotalCost",
each [Quantity] * [UnitPrice],
type number
)
Part 17: Demystifying the `each` Keyword
Power Query beginners ka sabse bada confusion: `each` kya hai?
The Big Truth: `each` is Pure Syntactic Sugar!
M language mein each koi loop ya keyword-magic nahi hai. Yeh ek anonymous lambda function ka shortcut hai jo ek single parameter _ (underscore) accept karta hai.
Method 1: Using `each` Shortcut
#"Add Bonus" = Table.AddColumn(
Source,
"Bonus",
each [Salary] * 0.10,
type number
)
Power Query UI isi format mein code generate karti hai.
Method 2: Under-the-Hood Equivalent
#"Add Bonus" = Table.AddColumn(
Source,
"Bonus",
(_) => _[Salary] * 0.10,
type number
)
Yahan _ poore current row ke Record ko represent karta hai!
Part 18: Custom Reusable Functions
Building modular, reusable M functions with typed signatures.
let
fxCalculateGST = (taxableAmount as number, gstRate as number) as record =>
let
tax = taxableAmount * (gstRate / 100),
total = taxableAmount + tax
in
[TaxAmount = tax, InvoiceTotal = total]
in
fxCalculateGST(10000, 18) // Output: [TaxAmount=1800, InvoiceTotal=11800]
Part 19: Error Handling (`try ... otherwise`)
Preventing report crashes on dirty or corrupt data values.
let
DirtyValue = "CorruptText",
SafeNumber = try Number.From(DirtyValue) otherwise 0
in
SafeNumber // Output: 0 (No crash!)
Part 20: Null Handling & Data Hygiene
Null propagation in arithmetic, replacing nulls, and filling down merged ERP rows.
#"Filled Down" = Table.FillDown(Source, {"Department", "ManagerName"})
Part 22: Relational Merges & 6 Join Kinds
Table.NestedJoin, Table.ExpandTableColumn, and JoinKind enum reference.
let
Merged = Table.NestedJoin(
Customers, {"CustomerID"},
Orders, {"CustomerID"},
"OrdersSubTable",
JoinKind.LeftOuter
),
Expanded = Table.ExpandTableColumn(
Merged,
"OrdersSubTable",
{"OrderID", "Amount"},
{"OrderID", "Amount"}
)
in
Expanded
Part 23: Group By & Aggregations (`Table.Group`)
Summarizing transactional tables and retaining nested sub-tables.
#"Grouped Region" = Table.Group(
Source,
{"Region"},
{
{"TotalSales", each List.Sum([SalesAmount]), type number},
{"OrderCount", each Table.RowCount(_), Int64.Type},
{"AverageTicket", each List.Average([SalesAmount]), type number}
}
)
Part 24: Reshaping Data: Pivot & Unpivot
Normalizing wide spreadsheet matrices for Power BI Star Schema.
#"Unpivoted Other" = Table.UnpivotOtherColumns(
Source,
{"ProductID", "ProductName"},
"MonthName",
"SalesRevenue"
)
Part 27: Multi-File Folder Consolidation
Combining 100+ Excel files from a folder automatically with zero manual copy-paste.
let
Source = Folder.Files("C:\MonthlyBranchReports\"),
Filtered = Table.SelectRows(Source, each [Extension] = ".xlsx" and not Text.StartsWith([Name], "~$")),
Extracted = Table.AddColumn(Filtered, "Data", each Excel.Workbook([Content], true){[Item="Sales", Kind="Table"]}[Data], type table),
Selected = Table.SelectColumns(Extracted, {"Name", "Data"}),
Expanded = Table.ExpandTableColumn(Selected, "Data", {"InvoiceID", "Customer", "Amount"}, {"InvoiceID", "Customer", "Amount"})
in
Expanded
Part 29: Tool Comparisons (M vs DAX vs Excel vs Python)
Where M fits in the modern enterprise BI ecosystem.
| Feature | Power Query M | DAX | Excel Formulas | Python (Pandas) |
|---|---|---|---|---|
| Core Purpose | ETL & Data Cleaning | Semantic Modeling / DAX Measures | Spreadsheet Grid Math | Data Science & ML |
| When Run? | Data Refresh time par | Visual Render / Slicer click par | Cell update par | Script execution runtime |
| Case Sensitivity | Strictly Case-Sensitive | Case-Insensitive | Case-Insensitive | Strictly Case-Sensitive |
| Evaluation | Functional Dependency Graph | In-Memory Tabular (VertiPaq) | Calculation Chain | Vectorized DataFrame |
Part 32: Performance Optimization & Query Folding
Pushing transformations down to the SQL database server for blazing fast refresh.
What is Query Folding?
Query Folding ka matlab hai: Power Query M ke transformation steps automatically source database ki native language (jaise SQL) mein translate hokar server par execute hote hain. Isse local PC par sirf filtered 5,000 rows aati hain, na ki 10 Crore rows!
Operations that Fold (Fast)
- Table.SelectRows (Filters)
- Table.RemoveColumns
- Table.RenameColumns
- Table.Group (Aggregations)
- Table.NestedJoin (Inner/Left Joins)
Operations that Break Folding (Slow)
- Custom M Functions
- Table.AddIndexColumn
- Merging disparate sources (SQL + Excel)
- Table.Buffer
Part 33: Diagnostic Guide & Common Errors
Identifying error messages, root causes, and production fixes.
| Error Message | Root Cause | How to Fix |
|---|---|---|
Expression.Error: The name 'X' wasn't recognized |
Function ya step name ki case-sensitivity galat hai. | PascalCase check karein: Text.Upper instead of text.upper. |
Token Comma expected |
let block ke step ke aakhir mein comma miss ho gaya hai. |
Har line ke end mein comma lagayein (except the last step). |
Formula.Firewall: Query references other queries... |
Do alag security privacy levels ke data sources merge ho rahe hain. | Staging queries isolate karein ya Privacy Levels matching set karein. |
The key didn't match any rows in the table |
Sheet name ya table name rename ho gaya hai. | Navigation step mein sheet name update karein ya positional index use karein. |
10 Real-World Enterprise Projects
Practical business scenarios with raw data, optimized M scripts, and step-by-step breakdown.
Project 1: Clean Dirty Customer Master Data
CRM se nikla data ganda hai: extra spaces, mixed uppercase/lowercase, irregular phone formatting (+91, hyphens, brackets).
let
Source = #table(
{"RawCustomerID", "RawCustomerName", "RawPhone", "RawEmail", "City"},
{
{" C001 ", " rAhUL sHaRMa ", "+91-98765-43210", "RAHUL.S@GMAIL.COM", "mumbai"},
{"C002", "PRIYA NAIR", "(022) 2854-1122", "priya_nair@yahoo.in", "Pune"},
{"C003", "vikas gupta", "91-9811122233", "vikas@corp.co", "DELHI"}
}
),
// Single-step optimized batch transformation
CleanedMaster = Table.TransformColumns(
Source,
{
{"RawCustomerID", Text.Trim, type text},
{"RawCustomerName", (name) => Text.Proper(Text.Trim(name)), type text},
{"RawPhone", (phone) => Text.End(Text.Select(phone, {"0".."9"}), 10), type text},
{"RawEmail", Text.Lower, type text},
{"City", Text.Proper, type text}
}
),
RenamedColumns = Table.RenameColumns(
CleanedMaster,
{
{"RawCustomerID", "CustomerID"},
{"RawCustomerName", "CustomerName"},
{"RawPhone", "MobileNumber"},
{"RawEmail", "EmailAddress"}
}
)
in
RenamedColumns
Project 2: Sales Data Cleaning & Safe Error Handling
E-commerce sales transaction table mein corrupt string values aur returns ko handle karna using try ... otherwise.
let
Source = #table(
{"OrderID", "GrossAmount", "Status"},
{
{101, 15000, "Delivered"},
{102, -2500, "Returned"},
{103, "CorruptValue", "Delivered"},
{104, 82000, "Delivered"}
}
),
// Safe conversion preventing crash
SafeAmounts = Table.AddColumn(
Source,
"CleanAmount",
each try Number.From([GrossAmount]) otherwise 0,
type number
),
AuditClassification = Table.AddColumn(
SafeAmounts,
"AuditFlag",
each if [CleanAmount] <= 0 then "Non-Revenue"
else if [CleanAmount] > 50000 then "High-Value"
else "Standard",
type text
)
in
AuditClassification
Project 3: Indian GST Tax Split (CGST + SGST vs IGST)
Intra-State (Same state) par CGST 9% + SGST 9%, jabki Inter-State (Different state) par IGST 18% dynamically calculate karna.
let
CompanyState = "Maharashtra",
Source = #table(
{"InvoiceNo", "CustomerState", "TaxableValue"},
{
{"INV-001", "Maharashtra", 100000},
{"INV-002", "Karnataka", 250000}
}
),
CalculatedTax = Table.AddColumn(
Source,
"TaxRecord",
each let
isLocal = [CustomerState] = CompanyState,
taxable = [TaxableValue],
cgst = if isLocal then taxable * 0.09 else 0,
sgst = if isLocal then taxable * 0.09 else 0,
igst = if not isLocal then taxable * 0.18 else 0,
total = taxable + cgst + sgst + igst
in
[CGST = cgst, SGST = sgst, IGST = igst, TotalInvoice = total],
type record
),
Expanded = Table.ExpandRecordColumn(
CalculatedTax,
"TaxRecord",
{"CGST", "SGST", "IGST", "TotalInvoice"}
)
in
Expanded
Project 5: Dynamic Multi-Excel Consolidation from Folder
Folder mein aane wali sabhi branch sales files ko automatically combine karna (ignoring temporary lock files).
let
Source = Folder.Files("C:\MonthlyBranchReports\"),
// Filter valid .xlsx files only
Filtered = Table.SelectRows(
Source,
each [Extension] = ".xlsx" and not Text.StartsWith([Name], "~$")
),
// Extract sheet data
Extracted = Table.AddColumn(
Filtered,
"SheetData",
each Excel.Workbook([Content], true){[Item="BranchSales", Kind="Table"]}[Data],
type table
),
Selected = Table.SelectColumns(Extracted, {"Name", "SheetData"}),
Expanded = Table.ExpandTableColumn(
Selected,
"SheetData",
{"InvoiceID", "InvoiceDate", "Customer", "Amount"},
{"InvoiceID", "InvoiceDate", "Customer", "Amount"}
)
in
Expanded
Project 10: Normalizing Flat Data into Power BI Star Schema
Ek single wide flat table ko Fact_Sales, Dim_Customer, aur Dim_Product tables mein split karna for blazing fast VertiPaq performance.
let
Source = FlatSalesData,
Selected = Table.SelectColumns(Source, {"CustomerID", "CustomerName", "CustomerCity"}),
Deduplicated = Table.Distinct(Selected, {"CustomerID"})
in
Deduplicated
110 Comprehensive Practice Exercises
Click on any question to view the problem, then click "Reveal Solution" to verify your M code.
Write an M query using let ... in to add 50 and 75.
let
X = 50,
Y = 75,
Total = X + Y
in
Total // Output: 125
let
BaseAmount = 12500,
GST = BaseAmount * 0.18
in
GST // Output: 2250
let
HundredNumbers = {1..100},
EvenNumbers = List.Select(HundredNumbers, each Number.Mod(_, 2) = 0)
in
EvenNumbers
Table.NestedJoin(
Customers, {"CustomerID"},
Orders, {"CustomerID"},
"CustomerOrders",
JoinKind.LeftOuter
)
Table.AddColumn(
Source,
"AgingBracket",
each let
today = DateTime.Date(DateTime.LocalNow()),
diffDays = Duration.Days(today - [InvoiceDate])
in
if diffDays <= 30 then "0-30 Days"
else if diffDays <= 60 then "31-60 Days"
else if diffDays <= 90 then "61-90 Days"
else ">90 Days",
type text
)
For all 110 numbered practice exercises and complete explanations, see Module 07 in your workspace.
52 Power Query M Interview Flashcards
Clear, concise Hinglish answers designed to crack high-paying Data Analyst & Power BI Developer roles.
Answer:
- Power Query M: Ek ETL (Data Preparation) Language hai jo data refresh ke waqt run hoti hai data ko clean aur shape karne ke liye. Yeh strictly case-sensitive hai.
- DAX: Ek Analytical / Semantic Modeling Language hai jo user ke slicer clicks aur report visual interactions ke waqt real-time filter context par run hoti hai. DAX case-insensitive hoti hai.
Answer:
Query Folding ek aisi capability hai jisme Power Query M ke transformations automatically source database ki native language (jaise SQL) mein translate hokar server par execute hote hain. Isse local machine par sirf filtered data transfer hota hai, jisse millions of rows ka refresh ghanton ke bajaye seconds mein complete ho jata hai.
Answer:
Applied Steps pane mein us step par Right-Click karein: Agar "View Native Query" enabled (clickable) hai → Query Folding active hai! Agar greyed out hai → Folding break ho chuki hai.
For all 52 technical interview questions and answers, see Module 08 in your workspace.
How to Publish This Course to GitHub & Cloudflare Pages
Follow these simple steps to host this web course live on Cloudflare Pages (pages.dev) for free!
Step 1: Push to GitHub
Git aur GitHub CLI already installed hain. Run in PowerShell:
cd C:\ANTIGRAVITY
gh auth login
gh repo create power-query-m-course --public --source=. --remote=origin --push
Step 2: Deploy to Cloudflare Pages (pages.dev)
- Login to dash.cloudflare.com.
- Navigate to Workers & Pages → Create Application → Pages → Connect to Git.
- Select
power-query-m-courserepo. - Set Framework:
None, Build Command: (empty), Output directory:/. - Click Save and Deploy!
- Live in 20 seconds at:
https://power-query-m-course.pages.dev!